CnC
Public Member Functions | List of all members
context< Derived > Class Template Reference

CnC context bringing together collections (for steps, items and tags). More...

Inherits context_base.

Public Member Functions

 context ()
 default constructor
 
virtual ~context ()
 destructor
 
error_type wait ()
 wait until all the steps prescribed by this context have completed execution. More...
 
void flush_gets ()
 used with the preschedule tuner to finalize 'gets' in the pre-execution of a step More...
 
void unsafe_reset ()
 
virtual void serialize (serializer &)
 (distCnC) overload this if default construction on remote processes is not enough.
 

Detailed Description

template<class Derived>
class CnC::context< Derived >

CnC context bringing together collections (for steps, items and tags).

The user needs to derive his or her own context from the CnC::context. The template argument to context is the user's context class itself.

For example,

struct my_context : public CnC::context< my_context >
{
my_context()
: CnC::context< my_context >(),
steps( this ),
oddNums( this ),
primes( this )
{
oddNums.prescribes( steps );
}
};

Several contexts can be created and executed simultaneously.

Execution starts as soon as a step(-instance) is prescribed through putting a tag. All ready steps will be executed even if CnC::context::wait() is never be called.

It is recommended to declare collections as members of a context derived from CnC::context. This yields more maintanable code and future versions of CnC may require this convention.

Definition at line 54 of file cnc.h.

Member Function Documentation

◆ flush_gets()

void flush_gets ( )

used with the preschedule tuner to finalize 'gets' in the pre-execution of a step

Call this after last call to the non-blocking item_collection::unsafe_get method.

◆ unsafe_reset()

void unsafe_reset ( )

reset all collections of this context

Note
not thread-safe, to be called in safe state only (between program start or calling context::wait() and putting the first tag or item).

◆ wait()

error_type wait ( )

wait until all the steps prescribed by this context have completed execution.

Returns
0 if succeeded, error code otherwise

The documentation for this class was generated from the following file: