CppELib 1.7.0
Loading...
Searching...
No Matches
OSWrapper::EventFlag Class Referenceabstract

Abstract class that has functions of common RTOS's event flag. More...

#include <EventFlag.h>

Public Types

enum  Mode { OR , AND }
 Used as argument of the wait methods. More...
 
typedef Container::BitPattern< unsigned int > Pattern
 Type for bit pattern of EventFlag.
 

Public Member Functions

virtual Error waitAny ()=0
 Block the current thread until any bit of this EventFlag is set ON.
 
virtual Error waitOne (std::size_t pos)=0
 Block the current thread until the bit at position pos of this EventFlag is set ON.
 
virtual Error wait (Pattern bitPattern, Mode waitMode, Pattern *releasedPattern)=0
 Block the current thread until the condition is satisfied.
 
virtual Error tryWaitAny ()=0
 Query without blocking whether any bit of this EventFlag is set ON.
 
virtual Error tryWaitOne (std::size_t pos)=0
 Query without blocking whether the bit at position pos of this EventFlag is set ON.
 
virtual Error tryWait (Pattern bitPattern, Mode waitMode, Pattern *releasedPattern)=0
 Query without blocking whether the condition is satisfied.
 
virtual Error timedWaitAny (Timeout tmout)=0
 Block the current thread until any bit of this EventFlag is set ON but only within the limited time.
 
virtual Error timedWaitOne (std::size_t pos, Timeout tmout)=0
 Block the current thread until the bit at position pos of this EventFlag is set ON but only within the limited time.
 
virtual Error timedWait (Pattern bitPattern, Mode waitMode, Pattern *releasedPattern, Timeout tmout)=0
 Block the current thread until the condition is satisfied but only within the limited time.
 
virtual Error setAll ()=0
 Set all the bits of this EventFlag object ON.
 
virtual Error setOne (std::size_t pos)=0
 Set the bit at position pos of this EventFlag object ON.
 
virtual Error set (Pattern bitPattern)=0
 Set the bits of bitPattern of this EventFlag object ON.
 
virtual Error resetAll ()=0
 Reset all the bits of this EventFlag object OFF.
 
virtual Error resetOne (std::size_t pos)=0
 Reset the bit at position pos of this EventFlag object OFF.
 
virtual Error reset (Pattern bitPattern)=0
 Reset the bits of bitPattern of this EventFlag object OFF.
 
virtual Pattern getCurrentPattern () const =0
 Get current bit pattern of this EventFlag object.
 

Static Public Member Functions

static EventFlagcreate (bool autoReset)
 Create an EventFlag object.
 
static void destroy (EventFlag *e)
 Destroy an EventFlag object.
 

Protected Member Functions

virtual ~EventFlag ()
 

Detailed Description

Abstract class that has functions of common RTOS's event flag.

Member Typedef Documentation

◆ Pattern

Type for bit pattern of EventFlag.

Member Enumeration Documentation

◆ Mode

Used as argument of the wait methods.

Enumerator
OR 
AND 

Constructor & Destructor Documentation

◆ ~EventFlag()

virtual OSWrapper::EventFlag::~EventFlag ( )
inlineprotectedvirtual

Member Function Documentation

◆ create()

EventFlag * OSWrapper::EventFlag::create ( bool  autoReset)
static

Create an EventFlag object.

Parameters
autoResetIf it is true then all the bits are automatically reset OFF when the wait methods succeeds
Returns
If this method succeeds then returns a pointer of EventFlag object, else returns null pointer

◆ destroy()

void OSWrapper::EventFlag::destroy ( EventFlag e)
static

Destroy an EventFlag object.

Parameters
ePointer of EventFlag object created by EventFlag::create()
Note
If e is null pointer, do nothing.

◆ getCurrentPattern()

virtual Pattern OSWrapper::EventFlag::getCurrentPattern ( ) const
pure virtual

Get current bit pattern of this EventFlag object.

Returns
Current bit pattern

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ reset()

virtual Error OSWrapper::EventFlag::reset ( Pattern  bitPattern)
pure virtual

Reset the bits of bitPattern of this EventFlag object OFF.

Let selfPattern is the bit pattern of this EventFlag object: Bitwise operation is (selfPattern &= ~bitPattern)

Parameters
bitPatternRequested bit pattern
Return values
OKAlways success

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ resetAll()

virtual Error OSWrapper::EventFlag::resetAll ( )
pure virtual

Reset all the bits of this EventFlag object OFF.

Return values
OKAlways success

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ resetOne()

virtual Error OSWrapper::EventFlag::resetOne ( std::size_t  pos)
pure virtual

Reset the bit at position pos of this EventFlag object OFF.

Parameters
posPosition of the bit
Return values
OKSuccess
InvalidParameterpos >= EventFlag::Pattern().size()

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ set()

virtual Error OSWrapper::EventFlag::set ( Pattern  bitPattern)
pure virtual

Set the bits of bitPattern of this EventFlag object ON.

Let selfPattern is the bit pattern of this EventFlag object: Bitwise operation is (selfPattern |= bitPattern)

Parameters
bitPatternRequested bit pattern
Return values
OKAlways success

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ setAll()

virtual Error OSWrapper::EventFlag::setAll ( )
pure virtual

Set all the bits of this EventFlag object ON.

Return values
OKAlways success

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ setOne()

virtual Error OSWrapper::EventFlag::setOne ( std::size_t  pos)
pure virtual

Set the bit at position pos of this EventFlag object ON.

Parameters
posPosition of the bit
Return values
OKSuccess
InvalidParameterpos >= EventFlag::Pattern().size()

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ timedWait()

virtual Error OSWrapper::EventFlag::timedWait ( Pattern  bitPattern,
Mode  waitMode,
Pattern releasedPattern,
Timeout  tmout 
)
pure virtual

Block the current thread until the condition is satisfied but only within the limited time.

Let selfPattern is the bit pattern of this EventFlag object:

  • If waitMode is EventFlag::OR, the condition is (selfPattern & bitPattern) != 0
  • If waitMode is EventFlag::AND, the condition is (selfPattern & bitPattern) == bitPattern

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
bitPatternRequested bit pattern
waitModeSpecify EventFlag::OR or EventFlag::AND
releasedPatternPointer of variable that stores the bit pattern of this EventFlag when the condition is satisfied. If null pointer, not accessed
tmoutThe limited time
Return values
OKSuccess. The condition is satisfied
TimedOutThe limited time was elapsed
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
InvalidParameterAll the bits of bitPattern are OFF, or waitMode is invalid value
Note
If tmout is Timeout::POLLING then this method queries whether the condition has been satisfied without blocking.
If tmout is Timeout::FOREVER then this method waits forever until the condition is satisfied.

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ timedWaitAny()

virtual Error OSWrapper::EventFlag::timedWaitAny ( Timeout  tmout)
pure virtual

Block the current thread until any bit of this EventFlag is set ON but only within the limited time.

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
tmoutThe limited time
Return values
OKSuccess. Any bit is set ON
TimedOutThe limited time was elapsed
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
Note
If tmout is Timeout::POLLING then this method queries whether the condition has been satisfied without blocking.
If tmout is Timeout::FOREVER then this method waits forever until the condition is satisfied.

Implemented in TestDoubleOSWrapper::TestDoubleEventFlag, and StdCppOSWrapper::StdCppEventFlag.

◆ timedWaitOne()

virtual Error OSWrapper::EventFlag::timedWaitOne ( std::size_t  pos,
Timeout  tmout 
)
pure virtual

Block the current thread until the bit at position pos of this EventFlag is set ON but only within the limited time.

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
posPosition of the bit
tmoutThe limited time
Return values
OKSuccess. The bit at position pos is set ON
TimedOutThe limited time was elapsed
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
InvalidParameterpos >= EventFlag::Pattern().size()
Note
If tmout is Timeout::POLLING then this method queries whether the condition has been satisfied without blocking.
If tmout is Timeout::FOREVER then this method waits forever until the condition is satisfied.

Implemented in TestDoubleOSWrapper::TestDoubleEventFlag, and StdCppOSWrapper::StdCppEventFlag.

◆ tryWait()

virtual Error OSWrapper::EventFlag::tryWait ( Pattern  bitPattern,
Mode  waitMode,
Pattern releasedPattern 
)
pure virtual

Query without blocking whether the condition is satisfied.

The condition is the same as timedWait().

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
bitPatternRequested bit pattern
waitModeSpecify EventFlag::OR or EventFlag::AND
releasedPatternPointer of variable that stores the bit pattern of this EventFlag when the condition is satisfied. If null pointer, not accessed
Return values
OKSuccess. The condition is satisfied
TimedOutThe bit pattern of this EventFlag object is not satisfied the condition
InvalidParameterAll the bits of bitPattern are OFF, or waitMode is invalid value
Note
Same as timedWait(bitPattern, waitMode, releasedPattern, Timeout::POLLING)

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ tryWaitAny()

virtual Error OSWrapper::EventFlag::tryWaitAny ( )
pure virtual

Query without blocking whether any bit of this EventFlag is set ON.

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Return values
OKSuccess. Any bit is set ON
TimedOutAll the bits of this EventFlag object are OFF
Note
Same as timedWaitAny(Timeout::POLLING)

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ tryWaitOne()

virtual Error OSWrapper::EventFlag::tryWaitOne ( std::size_t  pos)
pure virtual

Query without blocking whether the bit at position pos of this EventFlag is set ON.

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
posPosition of the bit
Return values
OKSuccess. The bit at position pos is set ON
TimedOutThe bit at position pos of this EventFlag object is OFF
InvalidParameterpos >= EventFlag::Pattern().size()
Note
Same as timedWaitOne(pos, Timeout::POLLING)

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ wait()

virtual Error OSWrapper::EventFlag::wait ( Pattern  bitPattern,
Mode  waitMode,
Pattern releasedPattern 
)
pure virtual

Block the current thread until the condition is satisfied.

The condition is the same as timedWait().

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
bitPatternRequested bit pattern
waitModeSpecify EventFlag::OR or EventFlag::AND
releasedPatternPointer of variable that stores the bit pattern of this EventFlag when the condition is satisfied. If null pointer, not accessed
Return values
OKSuccess. The condition is satisfied
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
InvalidParameterAll the bits of bitPattern are OFF, or waitMode is invalid value
Note
Same as timedWait(bitPattern, waitMode, releasedPattern, Timeout::FOREVER)

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ waitAny()

virtual Error OSWrapper::EventFlag::waitAny ( )
pure virtual

Block the current thread until any bit of this EventFlag is set ON.

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Return values
OKSuccess. Any bit is set ON
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
Note
Same as timedWaitAny(Timeout::FOREVER)

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.

◆ waitOne()

virtual Error OSWrapper::EventFlag::waitOne ( std::size_t  pos)
pure virtual

Block the current thread until the bit at position pos of this EventFlag is set ON.

If this EventFlag object has created with auto reset flag, when this method succeeds, the bit pattern of this EventFlag object is all reset OFF.

Parameters
posPosition of the bit
Return values
OKSuccess. The bit at position pos is set ON
CalledByNonThreadCalled from non thread context (interrupt handler, timer, etc)
InvalidParameterpos >= EventFlag::Pattern().size()
Note
Same as timedWaitOne(pos, Timeout::FOREVER)

Implemented in StdCppOSWrapper::StdCppEventFlag, and TestDoubleOSWrapper::TestDoubleEventFlag.


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