MCPcopy Create free account
hub / github.com/acl-dev/acl / pop

Method pop

lib_acl_cpp/include/acl_cpp/stdlib/tbox_array.hpp:142–169  ·  view source on GitHub ↗

* Receive message object * @param ms {int} When >= 0, set wait timeout (milliseconds), * otherwise wait forever until message object is read or error occurs * @param found {bool*} When not NULL, used to store whether a message object * was obtained, mainly used for * checking when passing null objects is allowed * @return {T*} Non-NULL indicates a message object was obtained. When re

Source from the content-addressed store, hash-verified

140 * @override
141 */
142 T* pop(int ms = -1, bool* found = NULL) {
143 long long us = ((long long) ms) * 1000;
144 bool found_flag;
145
146 if (! lock_.lock()) { abort(); }
147 while (true) {
148 T* t = peek(found_flag);
149 if (found_flag) {
150 if (! lock_.unlock()) { abort(); }
151 if (found) {
152 *found = found_flag;
153 }
154 return t;
155 }
156
157 // Note the call order, must call wait first then check wait_ms
158 waiters_++;
159 if (! cond_.wait(us, true) && us >= 0) {
160 waiters_--;
161 if (! lock_.unlock()) { abort(); }
162 if (found) {
163 *found = false;
164 }
165 return NULL;
166 }
167 waiters_--;
168 }
169 }
170
171 // @override
172 size_t pop( std::vector<T*>& out, size_t max, int ms) {

Callers

nothing calls this directly

Calls 5

peekFunction · 0.50
lockMethod · 0.45
unlockMethod · 0.45
waitMethod · 0.45
push_backMethod · 0.45

Tested by

no test coverage detected