MCPcopy Create free account
hub / github.com/facebook/CacheLib / enqueue

Method enqueue

cachelib/navy/scheduler/ThreadPoolJobQueue.cpp:43–63  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

41} // namespace
42
43void JobQueue::enqueue(Job job, folly::StringPiece name, QueuePos pos) {
44 bool wasEmpty = false;
45 {
46 std::lock_guard<std::mutex> lock{mutex_};
47 wasEmpty = queue_.empty() && processing_ == 0;
48 if (!stop_) {
49 if (pos == QueuePos::Front) {
50 queue_.emplace_front(std::move(job), name);
51 } else {
52 XDCHECK_EQ(pos, QueuePos::Back);
53 queue_.emplace_back(std::move(job), name);
54 }
55 enqueueCount_++;
56 }
57 maxQueueLen_ = std::max<uint64_t>(maxQueueLen_, queue_.size());
58 }
59
60 if (wasEmpty) {
61 cv_.notify_one();
62 }
63}
64
65void JobQueue::requestStop() {
66 std::lock_guard<std::mutex> lock{mutex_};

Callers 3

drainMethod · 0.80
onWorkerThreadMethod · 0.80
enqueueWithKeyMethod · 0.80

Calls 2

emptyMethod · 0.45
sizeMethod · 0.45

Tested by

no test coverage detected