Boost logo

Boost :

Subject: Re: [boost] [thread_pool] Dependencies between tasks
From: k-oli_at_[hidden]
Date: 2008-09-06 02:39:17


Am Samstag, 6. September 2008 06:40:03 schrieb vicente.botet:
> ----- Original Message -----
> From: "Kowalke Oliver (QD IT PA SI)" <Oliver.Kowalke_at_[hidden]>
> To: <boost_at_[hidden]>
> Sent: Friday, September 05, 2008 8:46 AM
> Subject: Re: [boost] [thread_pool] Dependencies between tasks
>
> > sequencing the access to the instance would be equivalent to chaining the
> > tasks (== chained tasks are executed after each other -> as a sequence).
> > take a look at thread_pool at the vault
> > http://www.boostpro.com/vault/index.php?action=downloadfile&filename=boos
> >t-threadpool.2.tar.gz&directory=Concurrent%20Programming&.
>
> Do you mean that each time the user wants to sequence tasks she/he needs
> * chain the task to the stored one
> * store the last task

I don't know what you mean with sore a task.

signature of chained_submit:

template<
      typename Act,
      typename T
>
    task< typename result_of< Act() >::type > chained_submit(
      Act const& act,
      task< T > & t);

The function object act which should be passed to the thread pool is chained
to the task t. This means - the function object act will be executed by I
worker thread if the task t was finished.

struct A
{
        void f( std::string const& str)
        { printf("A::f(): %s\n", str.c_str() ); }
};

struct B
{
        void g()
        { printf("B::g()\n"); }
};

                A a;
                B b;

                tp::pool<
                        tp::fixed,
                        tp::unbounded_channel< tp::fifo >
> pool( tp::max_poolsize( 5) );

                tp::task< void > t1(
                        pool.submit(
                                boost::bind(
                                        & A::f,
                                        a,
                                        "abc",
                                        2) ) );
                tp::task< void > t2(
                        pool.chained_submit(
                                boost::bind(
                                        & A::f,
                                        a,
                                        "efg",
                                        1),
                                t1) );
                tp::task< void > t3(
                        pool.chained_submit(
                                boost::bind(
                                        & A::f,
                                        a,
                                        "hij",
                                        0),
                                t2) );

                pool.submit(
                        boost::bind(
                                & B::g,
                                b) );

                t3.get_future().wait();

> I had already recovered your compressed file as other post let know. Please
> could you point me where the chaining task is described?

example_chained_submit and in the docu chapter 'Submiting Tasks'

> Thanks,
> Vicente

Oliver


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