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

Method push

src/util/threadsafe_limited_queue.h:17–33  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

15 void setMaxCapacity(size_t capacity) { max_capacity_ = capacity; }
16
17 void push(const T& value, size_t capacity, bool finished = false) {
18 CHECK(!done_) << "must not call push again if *finished* is set true";
19 if (capacity > max_capacity_) {
20 LL << "push obj with size " << capacity
21 << " into queue with capacity " << max_capacity_
22 << ". you will be blocked here forever...";
23 }
24 // do not insert
25 if (finished == false && capacity == 0) return;
26 std::unique_lock<std::mutex> l(mu_);
27 full_cond_.wait(l, [this, capacity]{
28 return (capacity + cur_capacity_ <= max_capacity_); });
29 queue_.push(std::move(std::make_pair(value, capacity)));
30 cur_capacity_ += capacity;
31 done_ = finished;
32 empty_cond_.notify_all();
33 }
34
35 bool pop(T& value) {
36 std::unique_lock<std::mutex> l(mu_);

Callers

nothing calls this directly

Calls 1

waitMethod · 0.80

Tested by

no test coverage detected