* 弹出节点,从头部进行 * @param task * @return */
| 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 | /** |
nothing calls this directly
no outgoing calls
no test coverage detected