Boost logo

Boost :

Subject: Re: [boost] [context] implementation comments
From: Oliver Kowalke (oliver.kowalke_at_[hidden])
Date: 2011-03-02 01:52:37


> also, both asym_fiber and sym_fiber have allocations;
>
> asym_fiber.hpp:51
>
> return detail::asym_fiber_base::ptr(
> do_return
> ? new detail::asym_fiber_object< void(*)() >( fn, stacksize,
> detail::asym_fiber_base::do_return)
> : new detail::asym_fiber_object< void(*)() >( fn, stacksize,
> detail::asym_fiber_base::do_not_return) );
>
> sym_fiber.hpp:51
>
> return detail::sym_fiber_base::ptr(
> new detail::sym_fiber_object< void(*)() >( fn, stacksize) );

the allocation is necessary for:
- support of efficient move semantics
- in order to accept arbitrary functions with arbitrary arguements in the ctor of a fiber
- the type asym_fiber and sym_fiber should not depend on the passed function (== the specific signature aof the function to be executed by the fiber doesn't influence the type of asym_fiber/sym_fiber) => you can store fiber objects which managing functions with different signature in the same container

asym_fiber_object is a template storing the functor which will be executed by the fiber.
asym_fiber_base is the interface asym_fiber_object dervies from.
this pattern allows to hide the specific functor signature

Oliver

 

-- 
Schon gehört? GMX hat einen genialen Phishing-Filter in die
Toolbar eingebaut! http://www.gmx.net/de/go/toolbar

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