changed BlockingQueue code style
This commit is contained in:
@@ -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;
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user