futureverse / futureverse/future
nbrOfFreeWorkers(): Automatic attempt to free up a worker, if there are no free workers left
- Dominant language
- R
- Stars
- 1k
- Forks
- 92
- PR merge metrics
- No merged PRs in 30d
Description
Distilled from :
Although rare, and probably a mistake, there are ways to end up with `nbrOfFreeWorkers() == 0`, even when some of the active futures have been resolved. In such cases, code that rely on `nbrOfFreeWorkers()` to decided whether to create another future might end up in a deadlock, e.g.
```r
if (nbrOfFreeWorkers() > 0) f <- future(...)
```
To account for such use as well, `nbrOfFreeWorkers()` could attempt an internal cleanup of registered futures in case there are no free workers available. Only if there are no free workers after such a cleanup, it should return `0`. Note that the internal cleanup will not block; it will check if any of the registered futures are resolved, and if one is, then its results are collected, allowing us to remove that future from the internal registry freeing up one worker.
/ht @randy3k
Contributor guide
Research direction
Start by locating the nbrOfFreeWorkers() entry point and reading how registered futures, worker availability, and resolved results are tracked. Verify the non-blocking cleanup behavior described in the issue and define completion as returning an available worker after resolved futures are collected, while still returning 0 when none can be freed.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- r
- Domain
- distributed-systems
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 38/100