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

Method pop

lib_acl_cpp/include/acl_cpp/stdlib/tbox.hpp:116–139  ·  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

114 * @override
115 */
116 T* pop(int ms = -1, bool* found = NULL) {
117 long long us = ((long long) ms) * 1000;
118 bool found_flag;
119 if (! lock_.lock()) { abort(); }
120 while (true) {
121 T* t = peek(found_flag);
122 if (found_flag) {
123 if (! lock_.unlock()) { abort(); }
124 if (found) {
125 *found = found_flag;
126 }
127 return t;
128 }
129
130 // Note the call order, must call wait first then check wait_ms
131 if (! cond_.wait(us, true) && us >= 0) {
132 if (! lock_.unlock()) { abort(); }
133 if (found) {
134 *found = false;
135 }
136 return NULL;
137 }
138 }
139 }
140
141 // @override
142 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