From: Braddock Gaskill (braddock_at_[hidden])
Date: 2007-03-24 09:20:35
I've started to use my futures implementation at
in a project.
I've come across a few cases where I need access to some of the
promise and future members (ready(), cancel(), etc), but don't actually
care about the type of the promise/future. For example, I have a
scheduler, and I want to be able to call
scheduler.post(f /* function */, p /* promise */)
where my scheduler can then add a cancelation handler to the promise,
possibly track if the future/promise has been fulfilled, cancel the
promise, etc, but yet has no need to know the type of the promise (which
would require a templated post() function).
I solved this problem by creating an "untyped_promise" class, which is
constructable from a typed promise<T>, but gives access to all methods of the
same promise instance, except for set() and get() obviously.
I was interested in thoughts on this untyped_promise.
Looking around, I found a post by Herb Sutter to the cpp-threads list where he
also considered this situation. He suggested making future<T> implicitly
convertible to future<void> so that future<void> could be used for this
purpose (not using a split future/promise concept). I kinda like that
idea actually. Thoughts?
Dockside Vision Inc