
Hi, https://github.com/olk/boost.context.git contains the new version of boost.context (docu at http://ok73.ok.funpic.de/boost/libs/context/doc/html/index.html) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review. regards, Oliver

Hi, I found a mistake in the documentation. In the "Terminating context<http://ok73.ok.funpic.de/boost/libs/context/doc/html/context/context.html#context.context.terminating_context>" exemples, there is no "do_return" passed to the constructer but a "no_return_to_caller" in both exemples. 2011/11/6 Oliver Kowalke <oliver.kowalke@gmx.de>
Hi,
https://github.com/olk/boost.**context.git<https://github.com/olk/boost.context.git>contains the new version of boost.context (docu at http://ok73.ok.funpic.de/**boost/libs/context/doc/html/**index.html<http://ok73.ok.funpic.de/boost/libs/context/doc/html/index.html> ) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review.
regards, Oliver
______________________________**_________________ Unsubscribe & other changes: http://lists.boost.org/** mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>

thx - I'll update the docu soon (it's not fully up-to-date). Oliver -------- Original-Nachricht --------
Datum: Mon, 7 Nov 2011 02:58:57 +0100 Von: ecyrbe <ecyrbe@gmail.com> An: boost@lists.boost.org Betreff: Re: [boost] [context] ready
Hi,
I found a mistake in the documentation. In the "Terminating context<http://ok73.ok.funpic.de/boost/libs/context/doc/html/context/context.html#context.context.terminating_context>" exemples, there is no "do_return" passed to the constructer but a "no_return_to_caller" in both exemples.
2011/11/6 Oliver Kowalke <oliver.kowalke@gmx.de>
Hi,
https://github.com/olk/boost.**context.git<https://github.com/olk/boost.context.git>contains the new version of boost.context (docu at
) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review.
regards, Oliver
______________________________**_________________ Unsubscribe & other changes: http://lists.boost.org/**
mailman/listinfo.cgi/boost<http://lists.boost.org/mailman/listinfo.cgi/boost>
_______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost
-- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

Hi there, I noticed this project and got really excited. Hopefully it won't meet the same fate as the coroutine library. Some comments: Pros: 1.) Impressive performance. Did you write some assembly for each platform to avoid having to swap out the signal masks and floating point context? 2.) Stack guard. This would be a huge win for me. Safety is always good. 3.) C++0x idioms. I'm glad to see movable being used. Cons: 1.) Void * argument passing. Perhaps there's some limitation that requires this. If so, then I'd be curious to read about it in the Rationale section. Even then, some syntactical sugar to hide the static cast may not be bad. 2.) Function pointers only? It looks like the library only accepts function pointers, not bound functions, functors, or lambdas. I suspect this is related to the fact that makecontext() accepts raw function pointers. Nevertheless, I've come to expect the ability to pass an arbitrary "callable" argument to boost libraries. If this is unreasonable, then I'd be curious to learn why in the Rationale section. Great work! Again, I'm really excited about the potential here, Taylor -----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Oliver Kowalke Sent: Sunday, November 06, 2011 5:20 AM To: boost@lists.boost.org Subject: [boost] [context] ready Hi, https://github.com/olk/boost.context.git contains the new version of boost.context (docu at http://ok73.ok.funpic.de/boost/libs/context/doc/html/index.html) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review. regards, Oliver _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost

hi Am 08.11.2011 18:22, schrieb GOODHART, TAYLOR:
1.) Impressive performance. Did you write some assembly for each platform to avoid having to swap out the signal masks and floating point context?
yes - currently supported: i386, x86_64, mips, arm, powerpc store/restore of the signal mask is not done and only required floating point stuff is preserved (like x87 control word on x86 etc.)
Cons: 1.) Void * argument passing. Perhaps there's some limitation that requires this. If so, then I'd be curious to read about it in the Rationale section. Even then, some syntactical sugar to hide the static cast may not be bad. 2.) Function pointers only? It looks like the library only accepts function pointers, not bound functions, functors, or lambdas. I suspect this is related to the fact that makecontext() accepts raw function pointers. Nevertheless, I've come to expect the ability to pass an arbitrary "callable" argument to boost libraries. If this is unreasonable, then I'd be curious to learn why in the Rationale section.
maybe you refer to the basic API boost_fcontext_jump()/boost_fcontext_make() etc? this interface is intended to be small as possible and was modelled like makecontext()/swapcontext() stuff. function pointers, bound functions, functors etc. can be used with the boost::context class (ctor similiar to boost::thread). the docu contains some out-dated infos - I've to update it. Oliver

Hi Oliver, Your work is appreciated, and I really want to try it, unfortunately it doesn't support MinGW yet. Here's my comments after looking the doc and codes: 1) The doc says suspend() throws nothing, but it does throw ex_unwind_stack for unwinding. Maybe it'd be better to make ex_unwind_stack part of API, and let the user catch and rethrow. 2) Many functions seem unnecessarily virtual, IMO, only dtor and exec need to be virtual. icontext could be replaced with platform-specific context_base without Allocator stored, and you could store Allocator in context_object instead, passing it to templated methods of context_base when needed (e.g. on constructon & cleanup).

Your work is appreciated, and I really want to try it, unfortunately it doesn't support MinGW yet.
maybe MinGW is supported later (requires only to adapt the Windows asm to GAS style + entry in Jamfile).
1) The doc says suspend() throws nothing, but it does throw ex_unwind_stack for unwinding. Maybe it'd be better to make ex_unwind_stack part of API, and let the user catch and rethrow.
ex_unwind_stack is swallowed by boost::context - it is required in order to implement expilict stack unwinding. It is important that the user dosn't swallow this exception! I think the best would be that the user dosn't know the type of this exception (unnamed exception?) - not sure if I should supress this info or note it explicitly in the docu.
2) Many functions seem unnecessarily virtual, IMO, only dtor and exec need to be virtual. icontext could be replaced with platform-specific context_base without Allocator stored, and you could store Allocator in context_object instead, passing it to templated methods of context_base when needed (e.g. on constructon & cleanup).
boost::context should be independed from the used Allocator. That requires that the pointer to the impl held inside boost::context doesn't contain the allocator type in its class declaration. Thatswhy icontext was introduced. context_base uses the allocator in order to allocate/deallocate the stack as well aplly it to fcontext_t. But maybe you can send me your solution so I can take alook at it? Oliver -- Empfehlen Sie GMX DSL Ihren Freunden und Bekannten und wir belohnen Sie mit bis zu 50,- Euro! https://freundschaftswerbung.gmx.de

2011/11/9 Oliver Kowalke <oliver.kowalke@gmx.de>
Your work is appreciated, and I really want to try it, unfortunately it doesn't support MinGW yet.
maybe MinGW is supported later (requires only to adapt the Windows asm to GAS style + entry in Jamfile).
Actually I've tried some MASM/GAS convert tools but with no luck :/
1) The doc says suspend() throws nothing, but it does throw ex_unwind_stack for unwinding. Maybe it'd be better to make ex_unwind_stack part of API, and let the user catch and rethrow.
ex_unwind_stack is swallowed by boost::context - it is required in order to implement expilict stack unwinding. It is important that the user dosn't swallow this exception! I think the best would be that the user dosn't know the type of this exception (unnamed exception?) - not sure if I should supress this info or note it explicitly in the docu.
Indeed the user should not swallow it, but there's no reason to prohibit the user from using catch(...) as well, so why not let the user catch and rethrow ex_unwind_stack explicitly for stack unwinding?
2) Many functions seem unnecessarily virtual, IMO, only dtor and exec need
to be virtual. icontext could be replaced with platform-specific context_base without Allocator stored, and you could store Allocator in context_object instead, passing it to templated methods of context_base when needed (e.g. on constructon & cleanup).
boost::context should be independed from the used Allocator. That requires that the pointer to the impl held inside boost::context doesn't contain the allocator type in its class declaration. Thatswhy icontext was introduced. context_base uses the allocator in order to allocate/deallocate the stack as well aplly it to fcontext_t.
But maybe you can send me your solution so I can take alook at it?
My solution is: remove icontext, use non-templated context_base directly. So it looks like: ////////////////// // platform-specific class context_base { public: typedef intrusive_ptr< context_base > ptr_t; template<class Allocator> context_base( Allocator& alloc, ...) { ... } template<class Allocator> void cleanup(Allocator& alloc) { // as in original dtor } virtual ~context_base() = 0; bool unwind_requested() const { ... } bool is_complete() const { ... } bool is_started() const { ... } bool is_resumed() const { ... } bool is_running() const { ... } void * start() { ... } void * resume( void * vp) { ... } void * suspend( void * vp) { ... } void unwind_stack() { ... } virtual void exec() = 0; }; template< typename Fn, typename Allocator > class context_object : public context_base { private: Fn fn_; Allocator alloc_; public: context_object(...) { ... } ~context_object() { cleanup(alloc_); } void exec() { fn_(); } }; ////////////////// Something I missed?

Actually I've tried some MASM/GAS convert tools but with no luck :/
it's not that difficult - the asm instructions remain the same - only syntax stuff matters (like the order of the operants etc.)
Indeed the user should not swallow it, but there's no reason to prohibit the user from using catch(...) as well, so why not let the user catch and rethrow ex_unwind_stack explicitly for stack unwinding?
I wouldn't use catch(...) in my code (maybe only in main) - anyway I'll make a note in the docu.
My solution is: remove icontext, use non-templated context_base directly. So it looks like:
<snip> OK - I got it and I'll take it into account. thx! Oliver -- NEU: FreePhone - 0ct/min Handyspartarif mit Geld-zurück-Garantie! Jetzt informieren: http://www.gmx.net/de/go/freephone

2011/11/9 Oliver Kowalke <oliver.kowalke@gmx.de>
My solution is: remove icontext, use non-templated context_base directly. So it looks like:
<snip>
OK - I got it and I'll take it into account. thx!
In the sample code I gave I forgot one important thing -- init order. Please apply trick like this: template< typename Fn, typename Allocator > class context_object : compressed_pair<Fn, Allocator>, public context_base {...}; By first private inheriting, the order is guaranteed and it's safe to pass allocator to context_base(...).

On Wednesday 09 November 2011 10:36:32 TONGARI wrote:
2011/11/9 Oliver Kowalke <oliver.kowalke@gmx.de>
ex_unwind_stack is swallowed by boost::context - it is required in order to implement expilict stack unwinding. It is important that the user dosn't swallow this exception! I think the best would be that the user dosn't know the type of this exception (unnamed exception?) - not sure if I should supress this info or note it explicitly in the docu.
Indeed the user should not swallow it, but there's no reason to prohibit the user from using catch(...) as well, so why not let the user catch and rethrow ex_unwind_stack explicitly for stack unwinding?
actually "catch(...)" not followed by "throw;" just causes lots of other problems (see for example http://udrepper.livejournal.com/21541.html) so that it should indeed be considered prohibited on a general basis Helge

On Wed, Nov 9, 2011 at 9:36 AM, TONGARI <tongari95@gmail.com> wrote:
2011/11/9 Oliver Kowalke <oliver.kowalke@gmx.de>
Your work is appreciated, and I really want to try it, unfortunately it doesn't support MinGW yet.
maybe MinGW is supported later (requires only to adapt the Windows asm to GAS style + entry in Jamfile).
Actually I've tried some MASM/GAS convert tools but with no luck :/
wasn't it possible to get GAS to swallow intel style asm?
1) The doc says suspend() throws nothing, but it does throw ex_unwind_stack for unwinding. Maybe it'd be better to make ex_unwind_stack part of API, and let the user catch and rethrow.
ex_unwind_stack is swallowed by boost::context - it is required in order to implement expilict stack unwinding. It is important that the user dosn't swallow this exception! I think the best would be that the user dosn't know the type of this exception (unnamed exception?) - not sure if I should supress this info or note it explicitly in the docu.
Indeed the user should not swallow it, but there's no reason to prohibit the user from using catch(...) as well, so why not let the user catch and rethrow ex_unwind_stack explicitly for stack unwinding?
It is technically possible to create an un-swallowable exception by retrowing '*this' in the exception destructor. IIRC g++ does exactly this for thread cancellation. I do not recomend this solution, though, as normally code does not expect it. I thik that the best thing to do woud be to document that the exception should be eventually rethrown at some point (not necessarily inside the catch(...) before resuming the calling (i.e. suspend()) context. suspend() should assert that the context has actually unwound. -- gpd

Am 09.11.2011 15:45, schrieb Giovanni Piero Deretta:
I thik that the best thing to do woud be to document that the exception should be eventually rethrown at some point (not necessarily inside the catch(...) before resuming the calling (i.e. suspend()) context. suspend() should assert that the context has actually unwound.
this is what function unwind_stack() does - so I'll update the docu and add a note related to this issue thx, Oliver

-----Original Message----- From: boost-bounces@lists.boost.org [mailto:boost-bounces@lists.boost.org] On Behalf Of Oliver Kowalke Sent: Sunday, November 06, 2011 4:20 AM To: boost@lists.boost.org Subject: [boost] [context] ready Hi, https://github.com/olk/boost.context.git contains the new version of boost.context (docu at http://ok73.ok.funpic.de/boost/libs/context/doc/html/index.html) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review. regards, Oliver _______________________________________________ Unsubscribe & other changes: http://lists.boost.org/mailman/listinfo.cgi/boost Here are some documentation changes: == Overview == thousends -> thousands == Synopsis == In order to implement rvalue references Boost.Move is used. Boost.Move is used to emulate rvalue references. If contexts are migrated between threads the code called by a context must not use thread-local-storage. If contexts are migrated between threads, the code called by a context must not use thread-local-storage. If fiber-local-storage is used on Windows the user is responsible to call ::FlsAlloc(), ::FlsFree(). If fiber-local-storage is used on Windows, the user is responsible for calling ::FlsAlloc(), ::FlsFree(). == Executing Context == A new context is created from a callable object (known as the context-function), the stack size and two arguments determine stack unwinding and context termination. A new context is created from a callable object (known as the context-function). The stack size, stack unwinding behavior, and context termination behavior are determined with additional arguments. If desired a function or callable object that requires arguments can be supplied by passing additional arguments to the context constructor. A function or callable object that requires arguments can have them supplied as additional arguments to the context constructor. Calling context::resume() from inside the same context undefined behaviour will happen. Calling context::resume() from inside the same context will result in undefined behaviour. The kernel does never 'see' the context switches. The kernel never 'sees' the context switches. Boost.Context allows to transfer data between contexts. context::resume() and context::suspend() accept a void pointer as argument and return a void pointer. The void pointer passed as argument to on of both functions is returned by its counterpart function. That means: the void pointer passed to context::resume() is returned by context::suspend() which was called in the other context (to which context::resume() transfers the execution cotnrol back). context::suspend() does the same, the void pointer arg is returned by context::resume() and context::start(), depending on which function was called before. context::start() has no void pointer argument because of it enters the context thus there is not return to context::suspend(). Boost.Context allows the transfer of data between contexts. Calls to context::resume() and context::suspend() both accept and return a void pointer. The void pointer passed as an argument to either function is returned by its counterpart function. I.e., the void pointer passed to context::resume() is returned by context::suspend() in the other context, and the void pointer passed to context::suspend() is returned by context::resume() or context::start(), depending on which function was called before. context::start() has no void pointer argument because it enters the start of the function, and there is no call to context::suspend() to return the value. == Exceptions in context function== The code executed by context may not use catch ellipses and swallow the exception used for unwinding the stack otherwise stack unwinding doesn't work. The code executed by context may not use catch ellipses and swallow the exception used for unwinding the stack. Doing so will cause stack unwinding to fail. == Linking context == Boost.Context provides the ability to link context instances. In the constructor of context the last argument is a reference to a context (which must not be a not-a-context). If a context becomes complete and a successor was defined then the context-function of the successor will be invoked. It is possible to create a chain of contexts and depending on the do_return argument in the constructor of the last context in the chain the application terminates or the execution control is transfered back to the last invokation of context::resume(). Each call of context::suspend() for the chained context instances will return to context::resume(). Boost.Context provides the ability to link context instances. In the constructor of context, the last argument is a reference to another context (which must not be a not-a-context). If a context becomes complete and a successor was defined, then the context-function of the successor will be invoked. In this way, it is possible to create a chain of contexts. Depending on the do_return argument in the constructor of the last context in the chain, the application terminates or the execution control is transferred back to the last invocation of context::resume(). Each call of context::suspend() for the chained context instances will return to context::resume(). == Unwinding stack == Sometimes it is necessary to unwind the stack of an unfinished context because of local variables on the stack which allocated resourcesi (RAII pattern). The next to last argumenti do_unwind of contexts constructor deterimes if the stack should be automaticaly unwound in the destructor of the context or not. The unwinding of the stack can be triggered by context::unwind_stack() too. Preconditions for stack unwinding are the the instance of context is not a not-a-context, the context is not complete, does own a stack and is not running. After unwinding the context is complete (postcondition). Sometimes it is necessary to unwind the stack of an unfinished context to destroy local stack variables (RAII pattern). The next to last argument of the context constructor, do_unwind, determines if the stack should be automatically unwound in the destructor of the context. The unwinding of the stack can be triggered by context::unwind_stack() too. Preconditions for stack unwinding are as follows: the instance of context is not a not-a-context, the context is not complete, the context does own a stack and is not running. After unwinding the context is complete (postcondition).

Keith Jeffery wrote:
Oliver Kowalke wrote:
https://github.com/olk/boost.context.git contains the new version of boost.context (docu at http://ok73.ok.funpic.de/boost/libs/context/doc/html/index.html) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review.
My corrections to Keith's corrections.
== Synopsis ==
If contexts are migrated between threads the code called by a context must not use thread-local-storage. If contexts are migrated between threads, the code called by a context must not use thread-local-storage.
Either "thread local storage" or "thread-local storage".
== Executing Context ==
A new context is created from a callable object (known as the context-function). The stack size, stack unwinding behavior, and context termination behavior are determined with ^^^^ by
additional arguments.
A function or callable object that requires arguments can have them supplied as additional arguments to the context constructor.
Additional arguments needed by a function or callable object are supplied as additional arguments to the context constructor.
The kernel never 'sees' the context switches.
The kernel is not involved in the context switches.
Calls to context::resume() and context::suspend() both accept and return a void pointer. The void pointer passed as an argument to either function is returned by its counterpart function. I.e., the void pointer passed to context::resume() is returned by context::suspend() in the other context, and the void pointer passed to context::suspend() is returned by context::resume() or context::start(), depending on which function was called before. context::start() has no void pointer argument because it enters the start of the function, and there is no call to context::suspend() to return the value.
The void pointer argument passed to context::resume(), in one context, is returned by context::suspend() in the other context. The void pointer passed to context::suspend(), in one context, is returned by context::resume() (or context::start(), depending upon which function was called previously) in the other context. Because context::start() has no void pointer argument, there is no corresponding context::suspend() call.
== Exceptions in context function==
The code executed by context may not use catch ellipses and swallow the exception used for unwinding the stack. Doing so will cause stack unwinding to fail.
Code executed by context must not prevent the propagation of the Boost.Context stack unwinding exception. Absorbing that exception will cause stack unwinding to fail. Thus, any code that catches all exceptions must rethrow the pending exception. (Can you simply name the exception type here rather than being circumspect? If so, replace "Boost.Context stack unwinding" with the type.)
== Linking context ==
In the constructor of context, the last argument is a reference to another context (which must not be a not-a- context). If a context becomes complete and a successor was
The last constructor argument is a reference to another context other than not-a-context. (The original phrasing used "a not-a-context". I haven't looked. Can there be more than one kind of a "not-a-context" or is that a sentinel state? If the latter, what I've written is correct. If not, then "a not-a-context" is better.)
defined, then the context-function of the successor will be invoked. In this way, it is possible to create a chain of contexts. Depending on the do_return argument in the constructor of the last context in the chain, the application terminates or the execution control is transferred back to the
s/the execution/execution/
last invocation of context::resume(). Each call of context::suspend() for the chained context instances will ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
, for the chained context instances,
return to context::resume().
== Unwinding stack ==
Sometimes it is necessary to unwind the stack of an unfinished context to destroy local stack variables (RAII pattern). The ^ so they can release allocated resources
next to last argument of the context constructor, do_unwind, determines if the stack should be automatically unwound in the destructor of the context.
s/determines...context/indicates whether the destructor should unwind the stack/
The unwinding of the stack can be triggered by context::unwind_stack() too.
Stack unwinding can also be triggered by calling context::unwind_stack().
Preconditions for stack unwinding are as follows: the instance of context is not a not-a-context, the context is not complete, the context does own a stack and is not running. After unwinding the context is complete (postcondition).
Stack unwinding assumes the following preconditions: * The context is not not-a-context * The context is not complete * The context is not running * The context owns a stack After unwinding, a context is complete. _____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components Susquehanna International Group, LLP http://www.sig.com ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.

Oliver Kowalke wrote:
boost.context (docu at http://ok73.ok.funpic.de/boost/libs/context/doc/html/index.html) Any comments are welcome - in the meantime I'm awaiting Giovanni's OK for the mini-review.
The following are some documentation comments. I may offer more later. A Motivation section would be useful on the initial page. Why would anyone want to use the library? What is a motivational use case that leads to using it and illustrates its capabilities? __________ Overview There are many issues with this section. Rather than list them exhaustively, allow me to offer a rewrite: "Boost.Context is a foundational library that provides a sort of cooperative multitasking on a single thread. (Contrast that with the preemptive multitasking of multithreaded programming.) By providing an abstraction of the current execution state in the current thread, including the stack (with local variables) and stack pointer, all registers and CPU flags, and the instruction pointer, a _context_ instance represents a specific point in the application's execution path. This is useful for building higher-level abstractions, like coroutines and fibers. "A _context_ provides the means to suspend the current execution path and to transfer execution control, thereby permitting another _context_ to run on the current thread. This stateful transfer mechanism enables a _context_ to suspend execution from within nested functions and, later, to resume from where it was suspended. While the execution path represented by a _context_ only runs on a single thread, it can be migrated to another thread at any given time. "A context switch between threads requires system calls (involving the OS kernel), which can cost thousands of CPU cycles on x86 CPUs. By contrast, transferring control among them requires only a few hundred CPU cycles because it does not involve system calls as it is done within a single thread." __________ Context The "Class context" link is out of place. It links to the synopsis, despite the name of the next section on context.html. _____ Synopsis This is not a synopsis, which should be the context class definition. It would appear that everything in this section would be better moved to the Context section at the top. In reading the Overview, I understood that a context can be migrated to a new thread as being passive. That is, that the kernel can change which thread executes the context. That seems reasonable. However, the warning in this section suggests that migration from one thread to another is not done passively, since the warning begins, "If contexts are migrated between threads". Perhaps you mean that if contexts are used in a multithreaded application, they can be migrated among threads and, therefore, cannot reference thread local storage. _____ Executing context The section name should be "Executing a context". In my correction to Keith Jeffery's correction of the second sentence in the first paragraph, I didn't think to note that it should be "by additional constructor arguments." 2nd para: "The context constructor uses a stack-allocator to allocate an associated stack, and the destructor uses the same stack-allocator to deallocate the stack. The default stack-allocator is stack_allocator, but a custom stack-allocator can be passed to the constructor." 4th para: "The context-function, as well as its arguments, if any, are copied into the context's state. If a reference is required, use boost::ref." 5th para: Merge this with the fourth paragraph. s/be changed/change in the future/ 6th para: "Calling context::start() transfers invokes the context-function in a newly created context complete with registers, flags, and stack and instruction pointers. When control should be returned to the original calling context, call context::suspend(). The current context information (registers, flags, and stack and instruction pointers) is saved and the original context information is restored. Calling context::resume() resumes execution in the second context. Note that context::start() must be called first and only once." The example code following the 6th paragraph is munged. Look at the three lines following the first use of std::cout. Warning: s/will result in/results in/ _____ Exceptions in context function The section name should be, "Exceptions in context-functions". 1st para: "If the context-function emits an exception, std::terminate() is called." _____ Terminating context 1st para, 1st sent: "The last context constructor argument is an enumerated type which determines what should happen when the context is complete (that is, when the context-function returns). The available values are return_to_caller and no_return_to_caller." 1st para, 2nd sent: This should be a separate paragraph in order to introduce the example code. It should then be reworded a bit (not to mention s/invokation/invocation/): "When the last constructor argument is return_to_caller, execution control is transferred back to the last invocation of context::start() or context::resume() when the context is complete, as shown in this example:". 2nd para: "When the last constructor argument is no_return_to_caller, the application terminates with an exit status of zero when the context is complete, as shown in the following example:". BTW, I should think "exit" would be a better name for no_return_to_caller. _____ Linking context This section name should be, "Chaining contexts". While they are being linked, it sounds better to say they are being chained together, because that implies the sequential execution nature of the relationship. Referring to the last constructor argument in this section and in the Terminating context section is confusing. I realize that there are overloads, and both references can be correct, but you need to reference these arguments differently. For example, you can refer to the "flat_return_t argument" and the "context argument". _____ Rob Stewart robert.stewart@sig.com Software Engineer using std::disclaimer; Dev Tools & Components Susquehanna International Group, LLP http://www.sig.com ________________________________ IMPORTANT: The information contained in this email and/or its attachments is confidential. If you are not the intended recipient, please notify the sender immediately by reply and immediately delete this message and all its attachments. Any review, use, reproduction, disclosure or dissemination of this message or any attachment by an unintended recipient is strictly prohibited. Neither this message nor any attachment is intended as or should be construed as an offer, solicitation or recommendation to buy or sell any security or other financial instrument. Neither the sender, his or her employer nor any of their respective affiliates makes any warranties as to the completeness or accuracy of any of the information contained herein or that this message or any of its attachments is free of viruses.
participants (8)
-
ecyrbe
-
Giovanni Piero Deretta
-
GOODHART, TAYLOR
-
Helge Bahmann
-
Keith Jeffery
-
Oliver Kowalke
-
Stewart, Robert
-
TONGARI