Boost logo

Boost :

Subject: [boost] [context] review
From: Gordon Woodhull (gordon_at_[hidden])
Date: 2011-03-27 08:48:18


Hi Oliver, Vicente, all,

Here is my uneducated review of the Context library.

I would like to see the library Accepted. However, I do not have the expertise to pore over assembly instructions, nor do I know whether this is the right approach.

I would probably be just as happy with a slower safe cross-platform library built on OS support, as with the fast (dangerous?) assembly version.

I hope that people who know better, like Giovanni and Holger, will continue to help make the library more robust.

> - What is your evaluation of the design?

From a user's perspective, it seems fairly clear how to use the library.

I thought I had understood from discussion that the class is moveable, but this didn't work for me. I ended up having to wrap contexts up in shared_ptrs in order to get my example to work (attached).

I am confident that higher-level libraries will take away the ugliness that arises from both coroutines in my example having to have access to the context for the other routine.

I admire the way Oliver split and then split his library again, to make this a very manageable library for review.

> - What is your evaluation of the implementation?

I only glanced at it.

> - What is your evaluation of the documentation?

The documentation is quite spare and completely lacks examples. It needs copy-editing (I can help there).

It also seems to be out of date. For example, it states: "To get the current user-level context boost::context::current() has to be called" but I couldn't find this function at all; it seems to have been replaced with the default-constructed context<>?

> - What is your evaluation of the potential usefulness of the library?

It would be great to have teleportation (or is it time travel? ;-) in C++. I expect this will unlock many interesting paradigms in addition to coroutines & generators.

I ran into a problem recently that I thought would be nicely solved if only I had coroutines. A parallelization framework had a callback when it needed more tasks to send out, and the routine that produced tasks was a hairy loop-of-loops. Neither could have its control inverted without making a big mess.

I've attached an extreme simplification of the problem (without the callback part that made it impossible to invert control).

> - Did you try to use the library? With what compiler? Did you have any
> problems?

Yes. I used Ubuntu 9.10 (in a VM), gcc version 4.4.1 (Ubuntu 4.4.1-4ubuntu8).

Since I used the review version from the vault and didn't do anything special, I think this means I used the ucontext version (how do I try fcontext? docs don't seem to explain how to choose.)

I had one problem which turned out to be a misunderstanding: I tried to construct a context with a next-context and then call it multiple times, but this crashed. In retrospect this isn't any better than a regular function call! and doesn't make much sense. But it would be good for the documentation to make it clear that a context is dead if the function returns.

> - How much effort did you put into your evaluation? A glance? A quick
> reading? In-depth study?

I spent a couple of hours reading docs and discussion, a few hours getting my example running, and an hour or two on writing this review.

> - Are you knowledgeable about the problem domain?

Color me interested but no expert.

Cheers,
Gordon




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