Open brycelelbach opened 6 years ago
Can you explain the differences between these?
Another I am interested in:
always_ready_future<T>
: A future type which is ready whenever it is valid; i.e. it is only created in the ready state. An inline_executor
which was also a twoway
executor could return such a future without having to pay the cost of a more expensive type of future.A two-way inline_executor that depends on a ready future could return a ready future. Otherwise I suspect it could not because it would have to know if the input future had completed yet. Having the type there would offer an interesting guarantee in the type system.
Related to always_ready_future<T>
is always_ready_error_future
. I've been toying around with the idea of creating one. It is interesting because it should probably be convertible to future<T>
with any T
, similar to unexpected<E>
for expected<T, E>
for any T
.
What about:
future
supported by a weakly concurrent agent that can't provide forward progress guarantees in the presence of blocking behavior(I know this sounds incredibly specific, but I feel like a lot of the discussions on some of the other issue threads, e.g. #5 , boil down to some variant of this)
Supported by in what sense?
The goal of my design sketch was that: 1) Setting callbacks is always safe from a weak agent. 2) Calling non-blocking execute or then_execute is similarly always safe (blocking is blocking, clearly, on some executors blocking might also be safe from a weak agent like a fiber) 3) future.wait() is safe on a weak agent only if the future resulted from a then_executor that is aware of the agent.
With that model you can always call .via(myexec).wait() safely from a weak agent that allows some level of blocking (like a fiber) and at least .execute(callback that satisfies something useful) otherwise.
Placeholder comment for "non-thread safe/single threaded shared-state futures". Example implementation adds callbacks to a thread-local work queue when runnable. This is the normal future type used in the nim programing language.