lparallel
lparallel copied to clipboard
Add a timeout option for `force`
It would be nice to have a way for force to timeout while waiting for a promise to be fulfilled.
Yes I had been thinking about try-force -- it's not in yet because the timeout option in bordeaux-threads is relatively recent and lparallel doesn't yet require it. Since futures can return multiple values, try-force may be a bit cumbersome, though, like (multiple-value-bind (vals success) (try-force f) ...).
This requires an additional slot for a condition variable in the future struct, which may be another reason that I avoided it. As with queues the cvar would be lazily created, but futures would be a little heavier nonetheless. Benchmarks probably won't be affected where waiting with timeout is never done.
One to deal with muliple values could be to signal a condition on a timeout, but that would be more cumbersome for the user to handle, and would be inconsistent with the timeout behavior for queues.