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

Method pop

lib_acl_cpp/include/acl_cpp.cn/stdlib/tbox.hpp:107–130  ·  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

105 * @override
106 */
107 T* pop(int ms = -1, bool* found = NULL) {
108 long long us = ((long long) ms) * 1000;
109 bool found_flag;
110 if (! lock_.lock()) { abort(); }
111 while (true) {
112 T* t = peek(found_flag);
113 if (found_flag) {
114 if (! lock_.unlock()) { abort(); }
115 if (found) {
116 *found = found_flag;
117 }
118 return t;
119 }
120
121 // ע�����˳�򣬱����ȵ��� wait ���ж� wait_ms
122 if (! cond_.wait(us, true) && us >= 0) {
123 if (! lock_.unlock()) { abort(); }
124 if (found) {
125 *found = false;
126 }
127 return NULL;
128 }
129 }
130 }
131
132 // @override
133 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