Browse Source

[2205] small refactoring: extracting send-command part to a thread

we'll use this pattern for other commands.
JINMEI Tatuya 12 years ago
parent
commit
f05b0be9d2
1 changed files with 7 additions and 5 deletions
  1. 7 5
      src/bin/auth/datasrc_clients_mgr.h

+ 7 - 5
src/bin/auth/datasrc_clients_mgr.h

@@ -89,17 +89,19 @@ public:
     {}
     ~DataSrcClientsMgrBase() {}
     void shutdown() {
+        sendCommand(internal::SHUTDOWN, data::ConstElementPtr());
+        builder_thread_.wait();
+    }
+
+private:
+    void sendCommand(internal::CommandID command, data::ConstElementPtr arg) {
         {
-            using namespace internal;
             typename MutexType::Locker locker(queue_mutex_);
-            command_queue_.push_back(Command(SHUTDOWN,
-                                             data::ConstElementPtr()));
+            command_queue_.push_back(internal::Command(command, arg));
         }
         cond_.signal();
-        builder_thread_.wait();
     }
 
-private:
     std::list<internal::Command> command_queue_;
     CondVarType cond_;
     MutexType queue_mutex_;