| 108 | } |
| 109 | |
| 110 | Event EventLog::waitForConnEvent(uint32_t connId, int64_t timeout) { |
| 111 | Synchronized s(monitor_); |
| 112 | |
| 113 | auto it = events_.begin(); |
| 114 | while (true) { |
| 115 | try { |
| 116 | // TODO: it would be nicer to honor timeout for the duration of this |
| 117 | // call, rather than restarting it for each call to wait(). It shouldn't |
| 118 | // be a big problem in practice, though. |
| 119 | while (it == events_.end()) { |
| 120 | monitor_.wait(timeout); |
| 121 | } |
| 122 | } catch (const TimedOutException &) { |
| 123 | return Event(ET_LOG_END, 0, 0, ""); |
| 124 | } |
| 125 | |
| 126 | if (it->connectionId == connId) { |
| 127 | Event event = *it; |
| 128 | events_.erase(it); |
| 129 | return event; |
| 130 | } |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } // apache::thrift::test |