MEL
Microthread & Execution library
mel::tasking Namespace Reference

Tasking system. More...

Classes

class  CriticalSection_mthread
 A critical section for synchronizing microthreads (AKA Process) More...
 
class  Lock_mthread
 
class  EventBase
 
class  EventMTThreadSafePolicy
 Policy for multithread safe event. More...
 
class  EventNoMTThreadSafePolicy
 Policy for non-multithread safe event. More...
 
class  Event_mthread
 class similar to Event Class (which is for thread synchronization) but for Process (with Microthread behaviour)
More...
 
class  GenericProcess
 A Process constructed from a functor with signature EGenericProcessResult(uint64_t,Process)*. More...
 
class  Process
 A periodic task, implementing a microthread. More...
 
class  ProcessScheduler
 
class  ProcessFactory
 Base factory class for tasks. More...
 
struct  DefaultAllocator
 Default allocator for new tasks (through Runnable::post) using the runnable default factory Runnable::getDefaultFactory. More...
 
class  Runnable
 A class representing a "running" task, with added functionality to post events requesting execution of external code within it. More...
 
class  ThreadRunnable
 Thread with Runnable behaviour. More...
 

Typedefs

typedef CallbackSubscriptor<::mel::core::CSMultithreadPolicy, std::shared_ptr< Process > > WakeSubscriptor
 
typedef CallbackSubscriptor<::mel::core::CSNoMultithreadPolicy, std::shared_ptr< Process > > SleepSubscriptor
 
typedef CallbackSubscriptor<::mel::core::CSNoMultithreadPolicy, std::shared_ptr< Process > > EvictSubscriptor
 

Enumerations

enum class  EEventMTWaitCode { EVENTMT_WAIT_OK , EVENTMT_WAIT_TIMEOUT , EVENTMT_WAIT_KILL }
 
enum class  EGenericProcessResult : char { CONTINUE , KILL }
 Result from functor used in a GenericProcess. More...
 

Functions

template<class ErrorType = mel::core::WaitErrorAsException, class T >
::mel::core::WaitResult< T > waitForFutureMThread (const mel::core::Future< T > &f, unsigned int msecs=EVENTMT_WAIT_INFINITE) noexcept(std::is_same< ErrorType, ::mel::core::WaitErrorNoException >::value)
 Waits for future completion, returning a wapper around the internal vale. More...
 
MEL_API ::mel::tasking::EEventMTWaitCode waitForBarrierMThread (const ::mel::parallelism::Barrier &b, unsigned int msecs=::mel::tasking::EVENTMT_WAIT_INFINITE)
 Wait for a barrier to activated in the context of a microthread.
 

Variables

static const int EVENTMT_WAIT_INFINITE = -1
 

Detailed Description

Tasking system.

Based on the concept of microthread, which is represented by class Process. A microthread alows to have cooperative multitasking, so that a single thread can execute thousands concurrent (in a cooperative sense ) tasks. Think microthread as a very light fiber

Enumeration Type Documentation

◆ EGenericProcessResult

Result from functor used in a GenericProcess.

Enumerator
CONTINUE 

Continue executing.

KILL 

Kill the process.

Function Documentation

◆ waitForFutureMThread()

template<class ErrorType = mel::core::WaitErrorAsException, class T >
::mel::core::WaitResult<T> mel::tasking::waitForFutureMThread ( const mel::core::Future< T > &  f,
unsigned int  msecs = EVENTMT_WAIT_INFINITE 
)
noexcept

Waits for future completion, returning a wapper around the internal vale.

Parameters
ErrorTypespecify how error is managed, by throwing an exception (if used mel::core::WaitErrorAsException) or not (uf used mel::core::WaitErrorNoException)
Exceptions
ifErrorType == mel::core::WaitErrorAsException, throws mel::core::WaitException if some error occured while waiting of the internal future exception if it has any error