]> Git Repo - VerusCoin.git/blobdiff - src/asyncrpcqueue.cpp
Auto rescan if note witnesses are off
[VerusCoin.git] / src / asyncrpcqueue.cpp
index 4994337c7a54e9ab6f338f29d04d3d8e1545a898..afe6d4bef02b2bc85b7f719e9c0c510295499e76 100644 (file)
@@ -31,7 +31,7 @@ void AsyncRPCQueue::run(size_t workerId) {
         AsyncRPCOperationId key;
         std::shared_ptr<AsyncRPCOperation> operation;
         {
-            std::unique_lock< std::mutex > guard(lock_);
+            std::unique_lock<std::mutex> guard(lock_);
             while (operation_id_queue_.empty() && !isClosed() && !isFinishing()) {
                 this->condition_.wait(guard);
             }
@@ -156,7 +156,7 @@ void AsyncRPCQueue::finish() {
  *  Call cancel() on all operations
  */
 void AsyncRPCQueue::cancelAllOperations() {
-    std::unique_lock< std::mutex > guard(lock_);
+    std::lock_guard<std::mutex> guard(lock_);
     for (auto key : operation_map_) {
         key.second->cancel();
     }
@@ -167,7 +167,7 @@ void AsyncRPCQueue::cancelAllOperations() {
  * Return the number of operations in the queue
  */
 size_t AsyncRPCQueue::getOperationCount() const {
-    std::unique_lock< std::mutex > guard(lock_);
+    std::lock_guard<std::mutex> guard(lock_);
     return operation_id_queue_.size();
 }
 
@@ -175,7 +175,7 @@ size_t AsyncRPCQueue::getOperationCount() const {
  * Spawn a worker thread
  */
 void AsyncRPCQueue::addWorker() {
-    std::unique_lock< std::mutex > guard(lock_); // Todo: could just have a lock on the vector
+    std::lock_guard<std::mutex> guard(lock_);
     workers_.emplace_back( std::thread(&AsyncRPCQueue::run, this, ++workerCounter) );
 }
 
@@ -183,6 +183,7 @@ void AsyncRPCQueue::addWorker() {
  * Return the number of worker threads spawned by the queue
  */
 size_t AsyncRPCQueue::getNumberOfWorkers() const {
+    std::lock_guard<std::mutex> guard(lock_);
     return workers_.size();
 }
 
@@ -190,7 +191,7 @@ size_t AsyncRPCQueue::getNumberOfWorkers() const {
  * Return a list of all known operation ids found in internal storage.
  */
 std::vector<AsyncRPCOperationId> AsyncRPCQueue::getAllOperationIds() const {
-    std::unique_lock< std::mutex > guard(lock_);
+    std::lock_guard<std::mutex> guard(lock_);
     std::vector<AsyncRPCOperationId> v;
     for(auto & entry: operation_map_) {
         v.push_back(entry.first);
@@ -220,7 +221,7 @@ void AsyncRPCQueue::finishAndWait() {
 void AsyncRPCQueue::wait_for_worker_threads() {
     // Notify any workers who are waiting, so they see the updated queue state
     {
-        std::unique_lock< std::mutex > guard(lock_);
+        std::lock_guard<std::mutex> guard(lock_);
         this->condition_.notify_all();
     }
         
This page took 0.027782 seconds and 4 git commands to generate.