Sylib
A C++ Library For V5
Loading...
Searching...
No Matches
sylib::SylibDaemon Class Reference

Sylib System Daemon. More...

#include <system.hpp>

Public Member Functions

void startSylibDaemon ()
 Starts the Sylib daemon. This should be called in initialize() or pre_auton() More...
 

Static Public Member Functions

static SylibDaemongetInstance ()
 Gets the single existing SylibDaemon object, or creates it if it doesn't exist yet. More...
 
static SylibDaemongetInstanceUnsafe ()
 Gets the single existing SylibDaemon object, or creates it if it doesn't exist yet. More...
 
static int managerTaskFunction ()
 The sole function that runs inside a task made specifically for the Sylib daemon. Contains an infinite loop that will prevent anything else from happening in the thread this is called in. More...
 
static int createSubTask (sylib::Device *objectPointerToSchedule)
 Adds a Device object or one of its child classes to the daemon's list of objects which need periodic updating. More...
 
static int createSubTaskUnsafe (sylib::Device *objectPointerToSchedule)
 Adds a Device object or one of its child classes to the daemon's list of objects which need periodic updating. More...
 
static void removeSubTask (sylib::Device *objectPointerToSchedule)
 Removes a Device object or one of its child classes from the daemon's list of objects which need periodic updating. More...
 
static void removeSubTaskByID (int idToKill)
 Removes a subtask from the daemon's list of objects which need periodic updating. More...
 
static uint64_t getFrameCount ()
 Gets the number of ticks of the Sylib daemon update loop. More...
 

Static Public Attributes

static sylib::Mutex mutex
 Mutex to prevent multiple threads from performing operations on important system things at once. More...
 

Detailed Description

Sylib System Daemon.

This is a singleton this is created when the first object that needs it is.

Takes care of running update functions that need to happen periodically.

Member Function Documentation

◆ createSubTask()

static int sylib::SylibDaemon::createSubTask ( sylib::Device objectPointerToSchedule)
static

Adds a Device object or one of its child classes to the daemon's list of objects which need periodic updating.

Parameters
objectPointerToScheduleA pointer to a Device object
Returns
The total number of subtasks created

◆ createSubTaskUnsafe()

static int sylib::SylibDaemon::createSubTaskUnsafe ( sylib::Device objectPointerToSchedule)
static

Adds a Device object or one of its child classes to the daemon's list of objects which need periodic updating.

Doesn't lock the mutex. This is used when creating objects in a global scope, before RTOS stuff has initialized and mutexes work.

Parameters
objectPointerToScheduleA pointer to a Device object
Returns
The total number of subtasks created

◆ getFrameCount()

static uint64_t sylib::SylibDaemon::getFrameCount ( )
static

Gets the number of ticks of the Sylib daemon update loop.

Should be approximately equal to the system timer divided by 2

Returns
Frame count

◆ getInstance()

static SylibDaemon & sylib::SylibDaemon::getInstance ( )
static

Gets the single existing SylibDaemon object, or creates it if it doesn't exist yet.

Returns
SylibDaemon object

◆ getInstanceUnsafe()

static SylibDaemon & sylib::SylibDaemon::getInstanceUnsafe ( )
static

Gets the single existing SylibDaemon object, or creates it if it doesn't exist yet.

Doesn't lock the mutex. This is used when creating objects in a global scope, before RTOS stuff has initialized and mutexes work.

Returns
SylibDaemon object

◆ managerTaskFunction()

static int sylib::SylibDaemon::managerTaskFunction ( )
static

The sole function that runs inside a task made specifically for the Sylib daemon. Contains an infinite loop that will prevent anything else from happening in the thread this is called in.

Returns
Theoretically 1, but this function should never return on account of the while(1) loop

◆ removeSubTask()

static void sylib::SylibDaemon::removeSubTask ( sylib::Device objectPointerToSchedule)
static

Removes a Device object or one of its child classes from the daemon's list of objects which need periodic updating.

Parameters
objectPointerToScheduleA pointer to a Device object

◆ removeSubTaskByID()

static void sylib::SylibDaemon::removeSubTaskByID ( int  idToKill)
static

Removes a subtask from the daemon's list of objects which need periodic updating.

Parameters
idToKillThe ID number of the subtask to remove

◆ startSylibDaemon()

void sylib::SylibDaemon::startSylibDaemon ( )

Starts the Sylib daemon. This should be called in initialize() or pre_auton()

Member Data Documentation

◆ mutex

sylib::Mutex sylib::SylibDaemon::mutex
static

Mutex to prevent multiple threads from performing operations on important system things at once.