|
Boost : |
Subject: Re: [boost] [threadpool] new version - fork/join (recursive/fibers)
From: Giovanni Piero Deretta (gpderetta_at_[hidden])
Date: 2008-11-04 17:42:03
On Tue, Nov 4, 2008 at 11:12 PM, Alexander Terekhov <terekhov_at_[hidden]> wrote:
>
> Giovanni Piero Deretta wrote:
>>
>> On Tue, Nov 4, 2008 at 9:35 PM, Alexander Terekhov <terekhov_at_[hidden]> wrote:
>> >
>> > k-oli_at_[hidden] wrote:
>> >
>> > [... fibers ...]
>> >
>> >> I'm open for discussion.
>> >
>> > First define 'fibers' in common sense language. This is a request for
>> > discussion to all. :-)
>> >
>>
>> Here goes a shot at a definition:
>> A fiber is a coperatively scheduled [purely/mostly userspace] thread
>> of execution. AKA (symmetric) coroutines, green threads, co-threads,
>> user contextes, etc.
>
> "A fiber is a unit of execution that must be manually scheduled by the
> application [do you really want and/or capable of that?].
asio io_service does most of the work.
> Fibers run in
> the context of the threads that schedule them [correct]. Each thread can
> schedule multiple fibers [correct]. In general, fibers do not provide
> advantages over a well-designed multithreaded application [that's
> right].
False. The reality is that fibers (and any type of user level threads)
scale much better than threads. Hundreds of thousands of fibers based
contextes are not unheard of in networked applications (think Erlang).
Using threads for that is overkill.
And you still have the advantage of cooperative scheduling (i.e. no
mutual exclusion). In fact cooperative multitasking is often a better
solution than threads to many problems.
> However, using fibers can make it easier to port applications
> that were designed to schedule their own threads [i.e. archaic academic
> coroutines apps]." Welcome back to the past.
>
Actually most programming languages of the last 20 years (i.e. younger
than C++) have fibers, or better, coroutines, in some form or another
(heck, even C# has generators).
Have you ever used a generator in python? That's a limited form of coroutines.
-- gpd
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk