Boost logo

Threads-Devel :

Subject: [Threads-devel] asio and future callbacks
From: Will Manley (boost_at_[hidden])
Date: 2010-08-02 04:16:27


Hi All

I was thinking of implementing a futures service following the asio
model of callbacks. This would essentially allow integrating use of
futures in the event based model of asio. I would imagine a class like:

class futures_service
{
public:
        futures_service(io_service& msg_queue);

        /// Register for a callback when the value contained in that
        /// future is ready. When the future is ready the handler will
        /// get posted to the message queue in a manner equivalent to
        /// calling io_service::dispatch.
        ///
        /// Handler should be a functor with the signature:
        /// void (Future_T&);
        template <class Future_T, class Handler>
        void wait_for_async(Future_T future, Handler cb);
};

The futures_service could be implemented using the same techniques as
boost::wait_for_any (thus would require access to private members of the
boost::future classes.

I have not come across anything like this in the boost libraries (either
in asio or threads). Has this been considered and rejected for some reason?

Thanks

Will

PS. Sorry for the cross-posting, it seemed relevant to both threads and
asio.


Threads-Devel list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk