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

Method pop

lib_acl_cpp/include/acl_cpp/stdlib/tbox2.hpp:95–110  ·  view source on GitHub ↗

* Receive message object * @param t {T&} Store result object when function returns true * @param ms {int} When >= 0, set wait timeout (milliseconds), * otherwise wait forever until message object is read or error occurs * @return {bool} Whether message object was obtained * @override */

Source from the content-addressed store, hash-verified

93 * @override
94 */
95 bool pop(T& t, int ms = -1) {
96 long long us = ((long long) ms) * 1000;
97 if (!lock_.lock()) { abort(); }
98 while (true) {
99 if (peek(t)) {
100 if (!lock_.unlock()) { abort(); }
101 return true;
102 }
103
104 // Note the call order, must call wait first then check wait_ms
105 if (!cond_.wait(us, true) && us >= 0) {
106 if (!lock_.unlock()) { abort(); }
107 return false;
108 }
109 }
110 }
111
112 // @override
113 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