1 #ifndef CAFFE2_UTILS_SIMPLE_QUEUE_H_ 2 #define CAFFE2_UTILS_SIMPLE_QUEUE_H_ 4 #include <condition_variable> 8 #include "caffe2/core/logging.h" 31 std::unique_lock<std::mutex> mutex_lock(mutex_);
32 while (queue_.size() == 0 && !no_more_jobs_) cv_.wait(mutex_lock);
33 if (queue_.size() == 0 && no_more_jobs_)
return false;
34 *value = queue_.front();
40 std::unique_lock<std::mutex> mutex_lock(mutex_);
45 void Push(
const T& value) {
47 std::lock_guard<std::mutex> mutex_lock(mutex_);
48 CAFFE_ENFORCE(!no_more_jobs_,
"Cannot push to a closed queue.");
62 std::lock_guard<std::mutex> mutex_lock(mutex_);
70 std::condition_variable cv_;
79 #endif // CAFFE2_UTILS_SIMPLE_QUEUE_H_
Simple registry implementation in Caffe2 that uses static variables to register object creators durin...