| 2735 | }; |
| 2736 | |
| 2737 | Status operator()(const std::shared_ptr<RecordBatch>& record) { |
| 2738 | std::unique_lock<std::mutex> lock(state_->mutex_); |
| 2739 | if (state_->pending_requests_ == 0) { |
| 2740 | state_->cv_.wait(lock, [this]() -> bool { |
| 2741 | return !state_->error_.ok() || state_->pending_requests_ > 0; |
| 2742 | }); |
| 2743 | } |
| 2744 | |
| 2745 | if (!state_->error_.ok()) { |
| 2746 | return state_->error_; |
| 2747 | } |
| 2748 | |
| 2749 | if (state_->pending_requests_ > 0) { |
| 2750 | state_->pending_requests_--; |
| 2751 | lock.unlock(); |
| 2752 | |
| 2753 | ArrowAsyncTask task; |
| 2754 | task.private_data = new PrivateTaskData{state_, record}; |
| 2755 | task.extract_data = AsyncProducer::extract_data; |
| 2756 | |
| 2757 | if (int status = handler_->on_next_task(handler_, &task, nullptr) != 0) { |
| 2758 | delete reinterpret_cast<PrivateTaskData*>(task.private_data); |
| 2759 | return Status::UnknownError("Received error from handler::on_next_task ", status); |
| 2760 | } |
| 2761 | } |
| 2762 | |
| 2763 | return Status::OK(); |
| 2764 | } |
| 2765 | |
| 2766 | static void request(struct ArrowAsyncProducer* producer, int64_t n) { |
| 2767 | auto* self = reinterpret_cast<State*>(producer->private_data); |
nothing calls this directly
no test coverage detected