MCPcopy Create free account
hub / github.com/dmlc/parameter_server / pop

Method pop

src/util/threadsafe_limited_queue.h:35–55  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33 }
34
35 bool pop(T& value) {
36 std::unique_lock<std::mutex> l(mu_);
37 // already finished
38 if (done_ && queue_.empty()) return false;
39
40 empty_cond_.wait(l, [this]{ return !queue_.empty(); });
41 std::pair<T, size_t> e = std::move(queue_.front());
42
43 // an empty item, which is inserted only when finished
44 if (e.second == 0) {
45 CHECK(done_);
46 return false;
47 }
48
49 // get a valid item
50 value = std::move(e.first);
51 cur_capacity_ -= e.second;
52 queue_.pop();
53 full_cond_.notify_all();
54 return true;
55 }
56
57 size_t size() const {
58 std::lock_guard<std::mutex> l(mu_);

Callers

nothing calls this directly

Calls 3

waitMethod · 0.80
frontMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected