
--- El mar 1-mar-11, Oliver Kowalke <oliver.kowalke@gmx.de> escribió:
context:
i noticed you migrate out of the context::create idiom and now context is noncopyable, so it seems right now the only way to have a recyclable context as a member is hold a
Fecha: martes, 1 de marzo de 2011, 15:08 Am 01.03.2011 16:45, schrieb Charlls Quarra: pointer/ref and allocate on the heap. This might be good for most use cases (which is probably the boost design principles) but i think it leaves out cases where, due to performance constraints, one either wants to recycle a context without touching the heap.
Which leaves me to my other comment; could you add an
template parameter for a allocator class so all new/delete operations are delegated to it?
you can not recycle the context -
fair enough
In order to prevent allocations and deallocations of the stack you could move-out the stack from a context instance an pass it to a newly created one.
context ctx1( ..., protected_stack(65536) ); ... protected_stack stk( ctx1.release_stack() ); ... context ctx2( ..., boost::move( stk) );
Allocators/deallocators are not used in favour of passing stack-objects to context-ctor.
this is good, but there are other allocations happening inside both context and fiber that the user has no control over. This might be smaller in comparison to the stack but they are there nonetheless. It would be better to leave the user to choose the allocator for any heap requests happening in the library. Charles J. Quarra