distortos  v0.7.0
object-oriented C++ RTOS for microcontrollers
Synchronization

Synchronization-related API of distortos. More...

Collaboration diagram for Synchronization:

Modules

 Queues
 Queues-related synchronization API of distortos.
 
 Signals
 Signals-related synchronization API of distortos.
 

Classes

class  distortos::ConditionVariable
 ConditionVariable is an advanced synchronization primitive. More...
 
class  distortos::Mutex
 Mutex is the basic synchronization primitive. More...
 
class  distortos::OnceFlag
 OnceFlag is a helper class for callOnce(). More...
 
class  distortos::Semaphore
 Semaphore is the basic synchronization primitive. More...
 

Functions

template<typename Function , typename... Args>
void distortos::callOnce (OnceFlag &onceFlag, Function &&function, Args &&... args)
 Executes the callable object exactly once, even if called from multiple threads. More...
 
int distortos::DynamicThread::join () override
 Waits for thread termination. More...
 
int distortos::internal::ThreadCommon::join () override
 Waits for thread termination. More...
 
virtual int distortos::Thread::join ()=0
 Waits for thread termination. More...
 

Detailed Description

Synchronization-related API of distortos.

Function Documentation

◆ callOnce()

template<typename Function , typename... Args>
void distortos::callOnce ( OnceFlag onceFlag,
Function &&  function,
Args &&...  args 
)

Executes the callable object exactly once, even if called from multiple threads.

Similar to std::call_once() - http://en.cppreference.com/w/cpp/thread/call_once Similar to POSIX pthread_once() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_once.html#

Warning
This function must not be called from interrupt context!
Template Parameters
Functionis the function object that will be executed
Argsare the arguments for Function
Parameters
[in]onceFlagis a reference to shared OnceFlag object
[in]functionis the function object that will be executed
[in]argsare arguments for function
Here is the call graph for this function:

◆ join() [1/3]

int distortos::internal::ThreadCommon::join ( )
overridevirtual

Waits for thread termination.

Similar to std::thread::join() - http://en.cppreference.com/w/cpp/thread/thread/join Similar to POSIX pthread_join() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html

Blocks current thread until this thread finishes its execution. The results of multiple simultaneous calls to join() on the same target thread are undefined.

Warning
This function must not be called from interrupt context!
Returns
0 on success, error code otherwise:
  • EDEADLK - deadlock condition was detected;
  • error codes returned by Semaphore::wait() (except EINTR);

Implements distortos::Thread.

Here is the call graph for this function:

◆ join() [2/3]

virtual int distortos::Thread::join ( )
pure virtual

Waits for thread termination.

Similar to std::thread::join() - http://en.cppreference.com/w/cpp/thread/thread/join Similar to POSIX pthread_join() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html

Blocks current thread until this thread finishes its execution. The results of multiple simultaneous calls to join() on the same target thread are undefined.

Warning
This function must not be called from interrupt context!
Returns
0 on success, error code otherwise:
  • EDEADLK - deadlock condition was detected,
  • EINVAL - this thread is not joinable,
  • ...

Implemented in distortos::DynamicThread, and distortos::internal::ThreadCommon.

◆ join() [3/3]

int distortos::DynamicThread::join ( )
overridevirtual

Waits for thread termination.

Similar to std::thread::join() - http://en.cppreference.com/w/cpp/thread/thread/join Similar to POSIX pthread_join() - http://pubs.opengroup.org/onlinepubs/9699919799/functions/pthread_join.html

Blocks current thread until this thread finishes its execution. The results of multiple simultaneous calls to join() on the same target thread are undefined.

Warning
This function must not be called from interrupt context!
Returns
0 on success, error code otherwise:

Implements distortos::Thread.