| 141 | } |
| 142 | |
| 143 | void BufferedPlanRootSink::Cancel(RuntimeState* state) { |
| 144 | DCHECK(state->is_cancelled()); |
| 145 | // Get the lock_ to synchronize with FlushFinal(). Either FlushFinal() will be waiting |
| 146 | // on the consumer_eos_ condition variable and get signalled below, or it will see |
| 147 | // that is_cancelled() is true after it gets the lock. Drop the the lock before |
| 148 | // signalling the CV so that a blocked thread can immediately acquire the mutex when |
| 149 | // it wakes up. |
| 150 | { |
| 151 | unique_lock<mutex> l(lock_); |
| 152 | } |
| 153 | // Wake up all sleeping threads so they can check the cancellation state. |
| 154 | // While it should be safe to call NotifyOne() here, prefer to use NotifyAll() to |
| 155 | // ensure that all sleeping threads are awoken. The calls to NotifyAll() are not on the |
| 156 | // fast path so any overhead from calling it should be negligible. |
| 157 | rows_available_.NotifyAll(); |
| 158 | consumer_eos_.NotifyAll(); |
| 159 | batch_queue_has_capacity_.NotifyAll(); |
| 160 | discard_result(all_results_spooled_.Set(false)); |
| 161 | } |
| 162 | |
| 163 | Status BufferedPlanRootSink::GetNext(RuntimeState* state, QueryResultSet* results, |
| 164 | int num_results, bool* eos, int64_t timeout_us) { |
no test coverage detected