mirror of
https://github.com/gabime/spdlog.git
synced 2025-03-01 03:35:50 +08:00
Small clean of enqueue_if_have_room in mpmc_blocking_q.h
This commit is contained in:
parent
214e26e8b2
commit
af8440b248
@ -47,20 +47,15 @@ public:
|
|||||||
}
|
}
|
||||||
|
|
||||||
void enqueue_if_have_room(T &&item) {
|
void enqueue_if_have_room(T &&item) {
|
||||||
bool pushed = false;
|
|
||||||
{
|
{
|
||||||
std::unique_lock<std::mutex> lock(queue_mutex_);
|
std::unique_lock lock(queue_mutex_);
|
||||||
if (!q_.full()) {
|
if (q_.full()) {
|
||||||
q_.push_back(std::move(item));
|
++discard_counter_;
|
||||||
pushed = true;
|
return;
|
||||||
}
|
}
|
||||||
|
q_.push_back(std::move(item));
|
||||||
}
|
}
|
||||||
|
push_cv_.notify_one();
|
||||||
if (pushed) {
|
|
||||||
push_cv_.notify_one();
|
|
||||||
} else {
|
|
||||||
++discard_counter_;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// dequeue with a timeout.
|
// dequeue with a timeout.
|
||||||
|
Loading…
Reference in New Issue
Block a user