
How do you store the function and function arguments passed to the context constructor?
the function arguments are bound with the function to a functor using boost::bind(). This functor is stored inside context_object class (derived from context_base (both in sub-namespace detail).
Ummm, okay, which begs the question: where does this context_object object live?
I'm using pimpl as member in context class (see below)
I couldn't find it in the documentation, and whatever the answer, seems like something that should be mentioned.
Hmm - it is an implementation detail. Should I document it in the 'Rational' section?
Well, it seems like you need to dynamically allocate *something*, and whether this is through operator new, the stack allocator (probably preferable...?), or something else, I think it should be documented
the pattern (using pimpl; type erasure of fn() and args) is also used by boost::thread and boost.threads docu does not document it because it is a implementation detail.
Okay. In other words: you can type-erase the context function quite easily, since you use the pimpl idiom anyway.
yes
On the other hand, type-erasing the data transferred between contexts would necessitate, e.g., boost::any, and hence a potentially unnecessary dynamic allocation and (maybe) dynamic dispatch.
you refering to context::supend()/context:.resume()? boost::any is not used. the lib does only transfer the pointer to the object/data between two contexts. I'm using simply an register to store the pointer (must also work on C too - if boost/config.hpp stuff becomes C conform) - because of performance reasons.
context ctx;
void f( int i) { ... char * x = "abc"; void * vp = ctx.suspend( x); double * d = static_cast< double >( vp);
Of course, you mean double* here, right? (If this is an actual example from the library, be sure to change it!)
typo - was only an example for the posting
I'm not sure who you mean by the "user".
user of boost.context
Just to be clear: I'm asking, what are the alignment requirements of the void* returned by allocate within the stack allocator concept? For those who want to create their own custom stack allocator.
there are no special alignment requirements - the lib does align the address returned by the stack allocator by itself (done inside boost_fcontext_make()).
I don't think it's a good idea to guarantee (as much as one is able to, anyway) a one-size-fits-all default stack size for all present and future platforms for all time and across all dimensions and parallel universes.
default_stacksize() was only introduced for more comfort for the lib users. I could also remove this function - but some user might ask what stacksize they should use.
That aside, can you provide some rationale for the specific choice of 256 kB? It seems rather...arbitrary, that's all. Indeed, I would've expected the default stack size to be somehow related to the platform word size (sizeof( void* ), maybe?).
I looked at the X11 server running on my system - and its stack size was between 200-400kb.
Just a nitpick on member variable names.
boost_fcontext_stack::ss_base/ss_limit: what does "ss" mean?
names base and limit are inspired by MS Windows Fiber API.
Hmmm...okay. That doesn't exactly answer my question, though :/
'ss' == stack-size Oliver -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone