Boost logo

Boost :

Subject: Re: [boost] [context] Implementation comments
From: Andrzej Krzemienski (akrzemi1_at_[hidden])
Date: 2011-01-19 06:40:20

>>> Why is boost::thread implemented with move-semantics?

>> Boost.Context is much more low level than Boost.Thread.
> why? thread and context are resources - I don't see context more low
> level than thread

Hold on. I understand that that you are saying that context is the same
level as thread. On the other hand in the reply to my question (about using
boost::function) you said

> boost.context is intended to be the basis of such things like coroutines
> (see boost.coroutine) and fibers (see boost.fiber).

Which somehow implied that Context is lower-level than Coroutine or Fiber.
If you really treat Context the same level as Thread, I would suggest
passing function<void()> as trampoline function. If you can afford using
pimpl, you can easily change function<void()> to void(*)(void*) and void*

  void call( void* arg) {
    auto ptr = static_cast< function<void()>* >( arg );

  function<void()> trampoline = ...;
  context_impl( call, &trampoline );

Using function<void()> makes it easier to understand for thread users and
makes the interface similar to thread, task, etc...


Boost list run by bdawes at, gregod at, cpdaniel at, john at