|
Boost : |
Subject: Re: [boost] Boost.Fiber review January 6-15
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2014-01-12 13:39:20
2014/1/11 Vicente J. Botet Escriba <vicente.botet_at_[hidden]>
> Le 11/01/14 19:45, Oliver Kowalke a écrit :
>
> 2014/1/11 Vicente J. Botet Escriba <vicente.botet_at_[hidden]>
>>
>> What would be the advantages of using work-stealing at the fiber level
>>> instead of using it at the task level?
>>>
>>> it is very simple because you migate a 'first-class' object, e.g. the
>> fiber
>> already is like a continuation.
>>
> yes, but what are the advantages? Does it performs better? It is easy to
> write them?
>
because creating depended tasks would not block your thread-pool.
suppose you have a thread-pool of M threads and you create (without
fiber-support) many tasks N.
some of the tasks create other task, executed in the pool, and wait on the
results.
if you have enough tasks N>>M all your worker-threads of the pool would be
blocked.
something like:
void tsk() {
...
for( int i = 0; i<X;++i) {
...
packaged_task<> p(some_other_tsk);
future<> f = p.get_future();
spawn( p);
f.get(); // blocks worker-thread
...
}
...
}
With fibers the code above (using packaged_task<> and future<> from
boost.fiber) does not
block the worker-thread.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk