Reference¶
Signatures¶
-
BlockLambda(auto &context, auto &variables)¶ Lambda that is passed to
stackless_coroutine::make_blockorstackless_coroutine::make_while_trueParameters: - context –
stackless_coroutine::context_type - variables – A reference to the coroutine variables class for this coroutine
- context –
-
FirstBlockLambda(auto &context, auto &variables, auto&&... coroutine_parameters)¶ First lambda that is passed to
stackless_coroutine::make_blockParameters: - context –
stackless_coroutine::context_type - variables – A reference to the coroutine variables class for this coroutine
- coroutine_parameters – Parameters that are passed to the coroutine
- context –
-
BlockLambdaAfterAsync(auto &context, auto &variables, auto&&... async_handler_parameters)¶ Lambda that follows a call to a async function
Parameters: - context –
stackless_coroutine::context_type - variables – A reference to the coroutine variables class for this coroutine
- parameters – Parameters that are passed to the async handler
- context –
-
CoroutineCompletionFunction(auto &variables, std::exception_ptr ep, stackless_coroutine::operation op)¶ Lambda or function that is passed in to
make_coroutineand is called exactly once upon completion of the coroutineParameters: - variables – A reference to the coroutine variables class for this coroutine
- ep – An exception_ptr that has any exception that escaped a
BlockLambda. If no exception occurred, will be empty - op –
Enumeration of
stackless_coroutine::operationwhich tells how the coroutine finishedstackless_coroutine::_done- Coroutine finished via exiting the lastBlockLambdawithout any exceptionsstackless_coroutine::_return- Coroutine finished viacontext.do_return()orcontext.do_async_return(). This indicates an early return.stackless_coroutine::_exception- Coroutine finished via an exception that escaped aBlockLambda. The exception will be inep.
Functions¶
All functions mentioned are in namespace stackless_coroutine
-
template<class ...
BlockFunction>
automake_block(BlockFunction&&... blockfunctions)¶ Makes a block which is analogous to a block or compound statement in C++. This consists of a sequence of BlockFunctions
Parameters: blockfunctions – Sequence of BlockFunctionsReturns: Returns a block which then may be passed to make_coroutine
-
template<class
CoroutineVariables, classBlock, classCoroutineCompletionFunction, class ...ConstructorArguments>
automake_coroutine(Block block, CoroutineCompletionFunction f, ConstructorArguments&&... arguments)¶ Makes a coroutine.
Parameters: - block – block created by call to
make_block - f –
CoroutineCompletionFunctionwhich will be called when coroutine finishes - arguments – Arguments to the construct of
CoroutineVariables
Returns: Returns a coroutine.
- block – block created by call to
-
template<class ...
BlockFunction>
automake_while_true(BlockFunction&&... blockfunctions)¶ Makes the equivalent of
while(true){...}` ``blockfunctionswill be executed repeatedly until one of the follow happens- Call to
context.do_return - Call to
context.do_async_return - An exception escapes a
BlockLambda
Parameters: blockfunctions – Sequence of BlockFunctionsReturns: Returns a BlockLambdafunctor which may be used anywhere aBlockLambdais used. This allowsmake_while_trueto be nested- Call to
Classes¶
All functions mentioned are in namespace stackless_coroutine
-
class
context_type¶ This is more a concept than a class. This is the type of
contextinBlockLambda-
template<class ...
T>
voidoperator()(T&&... t)¶ This will call the
BlockLambdaAfterAsyncpassingtas the arguments aftercontextandvariablesNote this is only available if theBlockLambdahasreturn context.do_async()
-
operation
do_return()¶ Does an early return from the coroutine
-
async_result
do_async_return()¶ Same as
do_return, but used in aBlockLambdathat callscontext.do_async()in one or more branches of the lambda
-
operation
do_break()¶ Analogous to
breakBreaks out of amake_while_trueloop
-
async_result
do_async_break()¶ Same as
do_break, but used in aBlockLambdathat callscontext.do_async()in one or more branches of the lambda
-
operation
do_continue()¶ Analogous to
continueGoes to the top of amake_while_trueloop
-
async_result
do_async_continue()¶ Same as
do_continue, but used in aBlockLambdathat callscontext.do_async()in one or more branches of the lambda
-
operation
do_next()¶ Goes to next
BlockLambdain the sequence
-
async_result
do_async()¶ Signals to stackless_coroutine that an async function with
contextas the callback has been called. The coroutine will be suspended until the async function callscontextresulting in theBlockLambdaAfterAsync(theBlockLambdafollowing thisBlockLambda) being called with the arguments the async function passed to the callback
-
static coroutine_context_t
get_context(void *v)¶ Creates a
coroutine_context_tfromvoid*which points to thevariablespassed toBlockLamda. The purpose of this static function is to enable easy interop with legacy C functions that take a function pointer and avoid*that will be passed to the function callback
-
template<class ...