changed BlockingQueue code style

This commit is contained in:
Neeflix
2018-05-31 20:52:08 +02:00
parent 89a6e04dfa
commit 8e742662a7

View File

@@ -23,21 +23,21 @@ private:
heap::priority_queue<T, heap::stable<T>> p_queue; heap::priority_queue<T, heap::stable<T>> p_queue;
public: public:
void push(T const& value) { void push(T const& value)
{ {
std::unique_lock<std::mutex> lock(this->d_mutex); std::unique_lock<std::mutex> lock(this->d_mutex);
p_queue.push_front(value); p_queue.push_front(value);
} this->d_condition.notify_one();
this->d_condition.notify_one(); }
}
T pop() { T pop()
std::unique_lock<std::mutex> lock(this->d_mutex); {
this->d_condition.wait(lock, [=]{ return !this->p_queue.empty(); }); std::unique_lock<std::mutex> lock(this->d_mutex);
T rc(std::move(this->p_queue.back())); this->d_condition.wait(lock, [=]{ return !this->p_queue.empty(); });
this->p_queue.pop_back(); T rc(std::move(this->p_queue.back()));
return rc; this->p_queue.pop_back();
} return rc;
}
}; };