| 235 | } |
| 236 | |
| 237 | BlockingReason LocalExchangeQueue::next( |
| 238 | ContinueFuture* future, |
| 239 | memory::MemoryPool* pool, |
| 240 | RowVectorPtr* data) { |
| 241 | std::vector<ContinuePromise> memoryPromises; |
| 242 | auto blockingReason = queue_.withWLock([&](auto& queue) { |
| 243 | *data = nullptr; |
| 244 | if (queue.empty()) { |
| 245 | if (isFinishedLocked(queue)) { |
| 246 | return BlockingReason::kNotBlocked; |
| 247 | } |
| 248 | |
| 249 | consumerPromises_.emplace_back("LocalExchangeQueue::next"); |
| 250 | *future = consumerPromises_.back().getSemiFuture(); |
| 251 | |
| 252 | return BlockingReason::kWaitForProducer; |
| 253 | } |
| 254 | *data = queue.front(); |
| 255 | queue.pop(); |
| 256 | memoryPromises = |
| 257 | memoryManager_->decreaseMemoryUsage((*data)->estimateFlatSize()); |
| 258 | |
| 259 | return BlockingReason::kNotBlocked; |
| 260 | }); |
| 261 | notify(memoryPromises); |
| 262 | return blockingReason; |
| 263 | } |
| 264 | |
| 265 | bool LocalExchangeQueue::isFinishedLocked( |
| 266 | const std::queue<RowVectorPtr>& queue) const { |
no test coverage detected