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