CMSDK 2.0.1
Cross-platform C++ base library and SDK for the Psyclone AIOS platform
Loading...
Searching...
No Matches
cmlabs::utils::Event Class Reference

Auto-reset notification event (condition variable style), optionally named for cross-process use. More...

#include <Utils.h>

Public Member Functions

 Event ()
 Create an anonymous, process-local event.
 Event (const char *name)
 Create or open a named, cross-process event.
 ~Event ()
bool waitNext ()
 Block until the next signal() occurs.
bool waitNext (uint32 timeout)
 Wait for a signal with a timeout.
bool signal ()
 Wake all threads currently waiting on this event.

Protected Attributes

char * name
pthread_cond_t * event
pthread_mutex_t * mutex

Detailed Description

Auto-reset notification event (condition variable style), optionally named for cross-process use.

Unlike a semaphore, signals are not counted: a signal wakes waiters that are currently blocked in waitNext(); there is no memory of past signals.

Definition at line 533 of file Utils.h.

Constructor & Destructor Documentation

◆ Event() [1/2]

cmlabs::utils::Event::Event ( )

Create an anonymous, process-local event.

Definition at line 1495 of file Utils.cpp.

References event, FALSE, mutex, name, and TRUE.

◆ Event() [2/2]

cmlabs::utils::Event::Event ( const char * name)

Create or open a named, cross-process event.

Parameters
nameGlobal name.

Definition at line 1512 of file Utils.cpp.

References cmlabs::utils::CreateSharedMemorySegment(), event, EVENTMEMSIZE, FALSE, MAXSHMEMNAMELEN, mutex, name, cmlabs::utils::OpenSharedMemorySegment(), TRUE, and WINSHMEMSPACE.

◆ ~Event()

cmlabs::utils::Event::~Event ( )

Definition at line 1553 of file Utils.cpp.

References cmlabs::utils::CloseSharedMemorySegment(), event, EVENTMEMSIZE, mutex, and name.

Member Function Documentation

◆ signal()

bool cmlabs::utils::Event::signal ( )

Wake all threads currently waiting on this event.

Returns
true on success.

Definition at line 1602 of file Utils.cpp.

References event, and mutex.

Referenced by cmlabs::PsySpace::emitSignal().

◆ waitNext() [1/2]

bool cmlabs::utils::Event::waitNext ( )

Block until the next signal() occurs.

Returns
true when signalled.

Definition at line 1578 of file Utils.cpp.

References event, and mutex.

Referenced by cmlabs::utils::WaitForNextEvent(), and cmlabs::PsySpace::waitForSignal().

◆ waitNext() [2/2]

bool cmlabs::utils::Event::waitNext ( uint32 timeout)

Wait for a signal with a timeout.

Parameters
timeoutMax wait in milliseconds.
Returns
true when signalled, false on timeout.

Definition at line 1589 of file Utils.cpp.

References cmlabs::utils::CalcTimeout(), event, and mutex.

Member Data Documentation

◆ event

pthread_cond_t* cmlabs::utils::Event::event
protected

Definition at line 552 of file Utils.h.

Referenced by Event(), Event(), signal(), waitNext(), waitNext(), and ~Event().

◆ mutex

pthread_mutex_t* cmlabs::utils::Event::mutex
protected

Definition at line 553 of file Utils.h.

Referenced by Event(), Event(), signal(), waitNext(), waitNext(), and ~Event().

◆ name

char* cmlabs::utils::Event::name
protected

Definition at line 548 of file Utils.h.

Referenced by Event(), Event(), and ~Event().


The documentation for this class was generated from the following files:
  • /home/ubuntu/c/partner/psyclone2/CMSDK/include/Utils.h
  • /home/ubuntu/c/partner/psyclone2/CMSDK/src/Utils.cpp