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

Method pop

lib_acl_cpp/include/acl_cpp.cn/stdlib/tbox_array.hpp:132–159  ·  view source on GitHub ↗

* ������Ϣ���� * @param ms {int} >= 0 ʱ���õȴ���ʱʱ��(���뼶��)�� * ������Զ�ȴ�ֱ��������Ϣ�������� * @param found {bool*} �ǿ�ʱ��������Ƿ�����һ����Ϣ������Ҫ���� * ���������ݿն���ʱ�ļ�� * @return {T*} �� NULL ��ʾ���һ����Ϣ���󣬷��� NULL ʱ����Ҫ����һ * ����飬��������� push ��һ���ն���NULL������������Ҳ���� NULL�� * ����ʱ��Ȼ��Ϊ�����һ����Ϣ����ֻ����Ϊ�ն������ wait_ms ���� * Ϊ -1 ʱ���� NULL ��Ȼ

Source from the content-addressed store, hash-verified

130 * @override
131 */
132 T* pop(int ms = -1, bool* found = NULL) {
133 long long us = ((long long) ms) * 1000;
134 bool found_flag;
135
136 if (! lock_.lock()) { abort(); }
137 while (true) {
138 T* t = peek(found_flag);
139 if (found_flag) {
140 if (! lock_.unlock()) { abort(); }
141 if (found) {
142 *found = found_flag;
143 }
144 return t;
145 }
146
147 // ע�����˳�򣬱����ȵ��� wait ���ж� wait_ms
148 waiters_++;
149 if (! cond_.wait(us, true) && us >= 0) {
150 waiters_--;
151 if (! lock_.unlock()) { abort(); }
152 if (found) {
153 *found = false;
154 }
155 return NULL;
156 }
157 waiters_--;
158 }
159 }
160
161 // @override
162 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