westonpace opened a new pull request #10258:
URL: https://github.com/apache/arrow/pull/10258
Previously a future's callbacks would always run synchronously, either as
part of `Future::MarkFinished` or as part of `Future::AddCallback`.
`Executor::Transfer` made it possible to schedule continuations on a new thread
but it would only take effect if the transferred future's callbacks were added
before the source future finished. There are times when the desired behavior
is to spawn a new thread task even if the source future is finished already.
This PR adds four scheduling options:
* Never - The default (and existing) behavior, never spawn a new task
* IfUnfinished - The default behavior for transfers, spawn a new task only
if the future isn't already finished
* IfIdle - A new behavior, spawn a new task as long as there is a core in
the destination thread pool that can process it
* Always - Always spawn a new task, on both finished and unfinished futures,
regardless of destination thread pool idleness.
This PR also adds a best effort "IsIdle" mechanism to the thread pool. It
is best effort because logic like...
```
if (pool->IsIdle()) {
pool->Submit(...);
}
```
...could still end up over-subscribing if tasks were added after the
`IsIdle` check and before the `Submit` check. However, this should be ok. An
alternative would be to do something like `TrySpawn` but that seemed like more
complexity than needed at the moment.
Leaving in draft until ARROW-12004 is merged as this one is built on top of
that one.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]