MCPcopy Create free account
hub / github.com/apache/impala / BlockingDrainTo

Method BlockingDrainTo

be/src/kudu/util/blocking_queue.h:120–143  ·  view source on GitHub ↗

Get all elements from the queue and append them to a vector. If 'deadline' passes and no elements have been returned from the queue, returns Status::TimedOut(). If 'deadline' is uninitialized, no deadline is used. If the queue has been shut down, but there are still elements waiting, then it returns those elements as if the queue were not yet shut down. Returns: - OK if successful - TimedOut if

Source from the content-addressed store, hash-verified

118 // - TimedOut if the deadline passed
119 // - Aborted if the queue shut down
120 Status BlockingDrainTo(std::vector<T>* out, MonoTime deadline = {}) {
121 MutexLock l(lock_);
122 while (true) {
123 if (!queue_.empty()) {
124 out->reserve(queue_.size());
125 for (const T& elt : queue_) {
126 decrement_size_unlocked(elt);
127 }
128 std::move(queue_.begin(), queue_.end(), std::back_inserter(*out));
129 queue_.clear();
130 l.Unlock();
131 not_full_.Signal();
132 return Status::OK();
133 }
134 if (PREDICT_FALSE(shutdown_)) {
135 return Status::Aborted("");
136 }
137 if (!deadline.Initialized()) {
138 not_empty_.Wait();
139 } else if (PREDICT_FALSE(!not_empty_.WaitUntil(deadline))) {
140 return Status::TimedOut("");
141 }
142 }
143 }
144
145 // Attempts to put the given value in the queue.
146 // Returns:

Callers 1

TESTFunction · 0.80

Calls 15

moveFunction · 0.85
OKFunction · 0.85
AbortedFunction · 0.85
TimedOutFunction · 0.85
reserveMethod · 0.80
clearMethod · 0.65
emptyMethod · 0.45
sizeMethod · 0.45
beginMethod · 0.45
endMethod · 0.45
UnlockMethod · 0.45
SignalMethod · 0.45

Tested by 1

TESTFunction · 0.64