Boost logo

Boost :

Subject: Re: [boost] Boost.Fiber review January 6-15
From: Eugene Yakubovich (eyakubovich_at_[hidden])
Date: 2014-01-10 13:32:51

On Fri, Jan 10, 2014 at 1:50 AM, Antony Polukhin <antoshkka_at_[hidden]> wrote:
> I'm slightly confused by the fact that fiber_base use many dynamic memory
> allocations (it contains std::vector, std::map) and virtual functions.
> There must be some way to optimize away that, otherwise fibers may be much
> slower than threads.
> Heap allocations also exist in mutex class. I dislike the `waiting_.
> push_back( n);` inside the spinlocked sections. Some intrusive container
> must be used instead of std::deque.

That's a good point. Since a fiber can only be in one waiting list at
a time, an intrusive list node can be placed right into the fiber_base
object. Alternatively, a node object can be allocated right on the
stack. It won't get destructed as the fiber suspends itself right
after putting itself into a wait queue (that's the way Linux kernel
does it). The only thing is I'm not sure if boost::intrusive supports
such usage.

Boost list run by bdawes at, gregod at, cpdaniel at, john at