Boost logo

Boost :

Subject: Re: [boost] [context] new version - support for Win64
From: Oliver Kowalke (k-oli_at_[hidden])
Date: 2011-01-15 10:33:16


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


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