MCPcopy Create free account
hub / github.com/ChunelFeng/CThreadPool / tryPop

Function tryPop

src/UtilsCtrl/ThreadPool/Queue/UWorkStealingQueue.h:48–61  ·  view source on GitHub ↗

* 弹出节点,从头部进行 * @param task * @return */

Source from the content-addressed store, hash-verified

46 * @return
47 */
48 CBool tryPop(UTask& task) {
49 // 这里不使用raii锁,主要是考虑到多线程的情况下,可能会重复进入
50 bool result = false;
51 if (mutex_.try_lock()) {
52 if (!deque_.empty()) {
53 task = std::move(deque_.front()); // 从前方弹出
54 deque_.pop_front();
55 result = true;
56 }
57 mutex_.unlock();
58 }
59
60 return result;
61 }
62
63
64 /**

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected