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

Time-binned activation queue used by a PsySpace to drive time-triggered modules. More...

#include <PsySpace.h>

Public Member Functions

 TimeQueue ()
 Create an empty time queue with its own timer.
 ~TimeQueue ()
 Destroy the queue and delete all remaining schedules (owned by the queue).
bool addSchedule (TimeQueueSchedule *schedule)
 Add a schedule to the queue.
bool removeSchedule (uint32 id)
 Remove (and delete) a schedule by id.
DataMessagewaitForNextEvent (uint32 ms)
 Block until the next scheduled event is due, or the timeout expires.

Detailed Description

Time-binned activation queue used by a PsySpace to drive time-triggered modules.

Holds a collection of TimeQueueSchedule entries and hands out activation messages in temporal order. A space thread blocks in waitForNextEvent() and dispatches the resulting DataMessage to the scheduled component. Thread-safe: internal mutex protects the schedule map; a semaphore wakes waiters when schedules change.

Definition at line 91 of file PsySpace.h.

Constructor & Destructor Documentation

◆ TimeQueue()

cmlabs::TimeQueue::TimeQueue ( )

Create an empty time queue with its own timer.

Definition at line 23 of file PsySpace.cpp.

◆ ~TimeQueue()

cmlabs::TimeQueue::~TimeQueue ( )

Destroy the queue and delete all remaining schedules (owned by the queue).

Definition at line 27 of file PsySpace.cpp.

Member Function Documentation

◆ addSchedule()

bool cmlabs::TimeQueue::addSchedule ( TimeQueueSchedule * schedule)

Add a schedule to the queue.

Parameters
scheduleSchedule to add; ownership transfers to the TimeQueue.
Returns
true if the schedule was accepted.

Definition at line 36 of file PsySpace.cpp.

References cmlabs::TimeQueueSchedule::end, cmlabs::TimeQueueSchedule::id, cmlabs::TimeQueueSchedule::interval, and cmlabs::TimeQueueSchedule::start.

◆ removeSchedule()

bool cmlabs::TimeQueue::removeSchedule ( uint32 id)

Remove (and delete) a schedule by id.

Parameters
idId of the schedule (TimeQueueSchedule::id).
Returns
true if a schedule with that id was found and removed.

Definition at line 47 of file PsySpace.cpp.

Referenced by Java_com_cmlabs_cmsdk_cmsdkJNI_TimeQueue_1removeSchedule().

◆ waitForNextEvent()

DataMessage * cmlabs::TimeQueue::waitForNextEvent ( uint32 ms)

Block until the next scheduled event is due, or the timeout expires.

Parameters
msMaximum time to wait, in milliseconds.
Returns
A newly generated activation DataMessage (caller takes ownership), or NULL on timeout.
Note
Blocking call; intended to be run from a dedicated space thread.

Definition at line 61 of file PsySpace.cpp.

References cmlabs::TimeQueueSchedule::msgTag, cmlabs::TimeQueueSchedule::msgType, and cmlabs::DataMessage::setTag().


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