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

Method pop

lib_acl_cpp/include/acl_cpp.cn/stdlib/tbox2.hpp:93–108  ·  view source on GitHub ↗

* ������Ϣ���� * @param t {T&} ������ ���� true ʱ��Ž������ * @param ms {int} >= 0 ʱ���õȴ���ʱʱ��(���뼶��)�� * ������Զ�ȴ�ֱ��������Ϣ�������� * @return {bool} �Ƿ�����Ϣ���� * @override */

Source from the content-addressed store, hash-verified

91 * @override
92 */
93 bool pop(T& t, int ms = -1) {
94 long long us = ((long long) ms) * 1000;
95 if (!lock_.lock()) { abort(); }
96 while (true) {
97 if (peek(t)) {
98 if (!lock_.unlock()) { abort(); }
99 return true;
100 }
101
102 // ע�����˳�򣬱����ȵ��� wait ���ж� wait_ms
103 if (!cond_.wait(us, true) && us >= 0) {
104 if (!lock_.unlock()) { abort(); }
105 return false;
106 }
107 }
108 }
109
110 // @override
111 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