executors / futures

A proposal for a futures programming model for ISO C++
22 stars 7 forks source link

Add conversion from any future to corresponding future<void> #59

Open hkaiser opened 6 years ago

hkaiser commented 6 years ago

In HPX we have added an implicit constructor future<void>::future(future<T> &&) (and shared_future<void>::shared_future(shared_future<T>)) allowing to convert any future to a corresponding Future<void>. This has proven to be very handy in many scenarios.

LeeHowes commented 6 years ago

I can't quite picture the useful scenarios, but I don't have a strong objection either. I wouldn't like to assume it can always be implemented with no cost, though. Obviously it could be always implemented via a continuation, but to do it cheaply you'd need to maintain some sort of knowledge that there is a mismatch between the shared state and what the future wants to do with the data. If it did require a continuation then it could be a pretty high cost implicit operation.

hkaiser commented 6 years ago

We have implemented it at no cost in HPX. It's a simple downcast on the shared state.

brycelelbach commented 6 years ago

Setting this as V1.5; we will discuss this and come to a conclusion before Rapperswil, but not before the mailing deadline due to time constraints.

hkaiser commented 6 years ago

@brycelelbach that's fine. We have a whole list of small helper facilities we can add at that point, then.