Boost logo

Boost :

Subject: Re: [boost] Futures Review - typeof registering
From: vicente.botet (vicente.botet_at_[hidden])
Date: 2009-01-10 09:15:32


Hi,

My use case is a function that request an asynchronous executor to fork all the functions given as parameter and returns a quite complex type

    template< typename AE, typename F1, ..., typename Fn>
    typename result_of::fork_all<AE, fusion::tuple<F1,..., Fn> >::type
    fork_all( AE& ae, F1 f1, ..., Fn fn );

and used as follows:

    bith::launcher ae;
    typedef bith::result_of::fork_all<bith::launcher ,boost::fusion::tuple<int(*)(),int(*)()> >::type auto_type;
    auto_type handles= bith::fork_all(ae, simple_thread, simple_thread);

For a launcher asynchronous executor,
    result_of::fork_all<AE, fusion::tuple<F1,..., Fn> >::type
is a
    boost::fusion::tuple<unique_future<result_of<Fk() ...>.

If we register unique_future on the Boost.Typeof library, we are able to write

    BOOST_AUTO(handles, bith::fork_all(ae, simple_thread, simple_thread));

which is much simpler.

Next follows the contents of the file. Could this file be added to the Boost.Future librarie?

Thanks,
Vicente

====================
// boost/futures/typeof/future.hpp
#ifndef BOOST_FUTURES_TYPEOF_FUTURE__HPP
#define BOOST_FUTURES_TYPEOF_FUTURE__HPP

#include <boost/futures/future.hpp>
#include <boost/typeof/typeof.hpp>

#include BOOST_TYPEOF_INCREMENT_REGISTRATION_GROUP()

BOOST_TYPEOF_REGISTER_TEMPLATE(boost::interthreads::unique_future, 1)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::interthreads::shared_future, 1)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::interthreads::promise, 1)
BOOST_TYPEOF_REGISTER_TEMPLATE(boost::interthreads::packaged_task, 1)

#endif
====================


Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk