| 34 | } |
| 35 | |
| 36 | void TAsyncSemaphore::Release() { |
| 37 | TPromise<TPtr> promise; |
| 38 | with_lock(Lock_) { |
| 39 | if (Cancelled_) { |
| 40 | return; |
| 41 | } |
| 42 | if (Promises_.empty()) { |
| 43 | ++Count_; |
| 44 | return; |
| 45 | } else { |
| 46 | promise = Promises_.front(); |
| 47 | Promises_.pop_front(); |
| 48 | } |
| 49 | } |
| 50 | promise.SetValue(this); |
| 51 | } |
| 52 | |
| 53 | void TAsyncSemaphore::Cancel() { |
| 54 | std::list<TPromise<TPtr>> promises; |
no test coverage detected