Re: [boost] [context] new version - support for Win64

I've uploaded boost.context-0.3.0.zip to boost vault.
Hi, I am new to the idea of context switching, and the idea seams very interesting. I have gotone question regarding the interface. The two arguments that are passed when creating a new context, of type void(*)(void*) and void* look like a way of providing a callback. I am used to, in Boost libraries and C++0x threads, to see function<void()> as a type of callbcak. Is there a reason for not using it in case of context switching? Regards, &rzej

using a simple function pointer and a void * as its argument makes the implementation in assembler easier. boost.context is intended to be the basis of such things like coroutines (see boost.coroutine) and fibers (see boost.fiber). Both libs allow to use arbitrary function objects. The function pointer is not a callback it is the function executed in the context and the void ptr is its argument. If you require to use boost.function you could easily create an object containing a boost::context and your boost:function instance. The context executes a trampoline function which will be invoked with the pointer to this object as argument. For more details look into boost.fiber. Am 18.12.2010 21:30, schrieb Andrzej Krzemienski:
I've uploaded boost.context-0.3.0.zip to boost vault.
Hi, I am new to the idea of context switching, and the idea seams very interesting. I have gotone question regarding the interface. The two arguments that are passed when creating a new context, of type void(*)(void*) and void* look like a way of providing a callback. I am used to, in Boost libraries and C++0x threads, to see function<void()> as a type of callbcak. Is there a reason for not using it in case of context switching?
Regards, &rzej _______________________________________________ Unsubscribe& other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

----- Original Message ----- From: "Oliver Kowalke" <k-oli@gmx.de> To: <boost@lists.boost.org> Sent: Saturday, December 18, 2010 10:01 PM Subject: Re: [boost] [context] new version - support for Win64
Am 18.12.2010 21:30, schrieb Andrzej Krzemienski:
I've uploaded boost.context-0.3.0.zip to boost vault.
Hi, I am new to the idea of context switching, and the idea seams very interesting. I have gotone question regarding the interface. The two arguments that are passed when creating a new context, of type void(*)(void*) and void* look like a way of providing a callback. I am used to, in Boost libraries and C++0x threads, to see function<void()> as a type of callbcak. Is there a reason for not using it in case of context switching? using a simple function pointer and a void * as its argument makes the implementation in assembler easier.
boost.context is intended to be the basis of such things like coroutines (see boost.coroutine) and fibers (see boost.fiber). Both libs allow to use arbitrary function objects.
I understand the rationale. Could this be added to the documentation in a FAQ section?
The function pointer is not a callback it is the function executed in the context and the void ptr is its argument.
If you require to use boost.function you could easily create an object containing a boost::context and your boost:function instance. The context executes a trampoline function which will be invoked with the pointer to this object as argument. For more details look into boost.fiber.
Could you add an example using something else than a void(*)(void*) entry? Thanks, Vicente

Am 15.01.2011 16:03, schrieb vicente.botet:
The function pointer is not a callback it is the function executed in the context and the void ptr is its argument.
If you require to use boost.function you could easily create an object containing a boost::context and your boost:function instance. The context executes a trampoline function which will be invoked with the pointer to this object as argument. For more details look into boost.fiber.
Could you add an example using something else than a void(*)(void*) entry?
quick: struct X { boost::context ctx; X(); void execute(); }; void trampoline( void * vp) { X * x = static_cast< X * >( vp); x->execute(); } X::X() : ctx( boost::context::create( trampoline, this) ) {} Oliver
participants (3)
-
Andrzej Krzemienski
-
Oliver Kowalke
-
vicente.botet