F´ Flight Software - C/C++ Documentation
A framework for building embedded system applications to NASA flight quality standards.
Os::ConditionVariableInterface Class Referenceabstract

interface for condition variables More...

#include <Os/ConditionVariableInterface.hpp>

Inheritance diagram for Os::ConditionVariableInterface:
Os::DelegateConditionVariable Os::Posix::Mutex::PosixConditionVariable Os::Stub::Mutex::StubConditionVariable

Public Types

enum  Status {
  OP_OK, ERROR_MUTEX_NOT_HELD, ERROR_DIFFERENT_MUTEX, ERROR_NOT_IMPLEMENTED,
  NOT_SUPPORTED, ERROR_OTHER
}
 

Public Member Functions

 ConditionVariableInterface ()=default
 Default constructor. More...
 
virtual ~ConditionVariableInterface ()=default
 Default destructor. More...
 
 ConditionVariableInterface (const ConditionVariableInterface &other)=delete
 copy constructor is forbidden More...
 
virtual ConditionVariableInterface & operator= (const ConditionVariableInterface &other)=delete
 assignment operator is forbidden More...
 
virtual Status pend (Os::Mutex &mutex)=0
 wait on a condition variable More...
 
virtual void notify ()=0
 notify a single waiter on this condition variable More...
 
virtual void notifyAll ()=0
 notify all waiters on this condition variable More...
 
virtual ConditionVariableHandle * getHandle ()=0
 return the underlying condition variable handle (implementation specific). More...
 
void wait (Os::Mutex &mutex)
 wait on a condition variable and assert success More...
 

Static Public Member Functions

static ConditionVariableInterface * getDelegate (ConditionVariableHandleStorage &aligned_new_memory)
 provide a pointer to a ConditionVariable delegate object More...
 

Detailed Description

interface for condition variables

Condition variables allow a program to block on a condition while atomically releasing an Os::Mutex and atomically reacquiring the mutex once the condition has been notified.

Definition at line 34 of file ConditionVariableInterface.hpp.

Member Enumeration Documentation

◆ Status

Enumerator
OP_OK 

Operation was successful.

ERROR_MUTEX_NOT_HELD 

When trying to wait but we don't hold the mutex.

ERROR_DIFFERENT_MUTEX 

When trying to use a different mutex than expected mutex.

ERROR_NOT_IMPLEMENTED 

When trying to use a feature that isn't implemented.

NOT_SUPPORTED 

ConditionVariable does not support operation.

ERROR_OTHER 

All other errors.

Definition at line 36 of file ConditionVariableInterface.hpp.

Constructor & Destructor Documentation

◆ ConditionVariableInterface() [1/2]

Os::ConditionVariableInterface::ConditionVariableInterface ( )
default

Default constructor.

◆ ~ConditionVariableInterface()

virtual Os::ConditionVariableInterface::~ConditionVariableInterface ( )
virtualdefault

Default destructor.

◆ ConditionVariableInterface() [2/2]

Os::ConditionVariableInterface::ConditionVariableInterface ( const ConditionVariableInterface &  other)
delete

copy constructor is forbidden

Member Function Documentation

◆ getDelegate()

ConditionVariableInterface * Os::ConditionVariableInterface::getDelegate ( ConditionVariableHandleStorage &  aligned_new_memory)
static

provide a pointer to a ConditionVariable delegate object

get a delegate for condition variable

get a delegate for MutexInterface that intercepts calls for Posix

Note
ERROR_DIFFERENT_MUTEX is reported by the link-time Os::DelegateConditionVariable, which records the mutex first supplied to pend(); an implementation selected directly as Os::ConditionVariable does not perform that check.
Parameters
aligned_new_memoryaligned memory to fill
Returns
: pointer to delegate

Definition at line 20 of file DefaultMutex.cpp.

◆ getHandle()

virtual ConditionVariableHandle* Os::ConditionVariableInterface::getHandle ( )
pure virtual

return the underlying condition variable handle (implementation specific).

Returns
internal task handle representation

Implemented in Os::DelegateConditionVariable, Os::Posix::Mutex::PosixConditionVariable, and Os::Stub::Mutex::StubConditionVariable.

◆ notify()

virtual void Os::ConditionVariableInterface::notify ( )
pure virtual

notify a single waiter on this condition variable

Notify a single waiter on this condition variable. It is not necessary to hold the mutex supplied by the waiters and it is advantageous not to hold the lock to prevent immediate re-blocking.

Implemented in Os::DelegateConditionVariable, Os::Posix::Mutex::PosixConditionVariable, and Os::Stub::Mutex::StubConditionVariable.

◆ notifyAll()

virtual void Os::ConditionVariableInterface::notifyAll ( )
pure virtual

notify all waiters on this condition variable

Notify all waiters on this condition variable. It is not necessary to hold the mutex supplied by the waiters and it is advantageous not to hold the lock to prevent immediate re-blocking.

Implemented in Os::DelegateConditionVariable, Os::Posix::Mutex::PosixConditionVariable, and Os::Stub::Mutex::StubConditionVariable.

◆ operator=()

virtual ConditionVariableInterface& Os::ConditionVariableInterface::operator= ( const ConditionVariableInterface &  other)
virtualdelete

◆ pend()

virtual Status Os::ConditionVariableInterface::pend ( Os::Mutex &  mutex)
pure virtual

wait on a condition variable

Wait on a condition variable. This function will atomically unlock the provided mutex and block on the condition in one step. Blocking will occur until a future notify or notifyAll call is made to this variable on another thread of execution.

Parameters
mutexmutex to unlock as part of this operation
Returns
status of the conditional wait

Implemented in Os::DelegateConditionVariable, Os::Posix::Mutex::PosixConditionVariable, and Os::Stub::Mutex::StubConditionVariable.

◆ wait()

void Os::ConditionVariableInterface::wait ( Os::Mutex &  mutex)
inline

wait on a condition variable and assert success

Wait on a condition variable. This function will atomically unlock the provided mutex and block on the condition in one step. Blocking will occur until a future notify or notifyAll call is made to this variable on another thread of execution.

Warning
it is invalid to supply a mutex different from those supplied by others
conditions must be rechecked after the condition variable unlocks
the mutex must be locked by the calling task
Parameters
mutexmutex to unlock as part of this operation

Definition at line 106 of file ConditionVariableInterface.hpp.


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