StuBS
Bellringer Class Reference

Manages and activates time-triggered activities. More...

#include <sync/bellringer.h>

Collaboration diagram for Bellringer:
[legend]

Static Public Member Functions

static void check ()
 Checks whether there are bells to be rung.
 
static void job (Bell *bell, unsigned int ms)
 Passes a bell to the bellringer to be rung after ms milliseconds.
 
static void cancel (Bell *bell)
 Cancel ticking & ringing a bell.
 
static bool bellPending ()
 Checks whether there are enqueued bells.
 

Private Member Functions

 Bellringer ()
 
 Bellringer (const Bellringer &)=delete
 
Bellringeroperator= (const Bellringer &)=delete
 

Static Private Attributes

static GlobalQueue< Bellbells
 List of bells currently managed.
 

Detailed Description

Manages and activates time-triggered activities.

The Bellringer is regularly activated and checks whether any of the bells should ring. The bells are stored in a Queue<Bell> that is managed by the Bellringer. A clever implementation avoids iterating through the whole list for every iteration by keeping the bells sorted and storing delta times. This approach leads to a complexity of O(1) for the method called by the timer interrupt in case no bells need to be rung.

Constructor & Destructor Documentation

◆ Bellringer() [1/2]

Bellringer::Bellringer ( )
private

◆ Bellringer() [2/2]

Bellringer::Bellringer ( const Bellringer )
privatedelete

Member Function Documentation

◆ operator=()

Bellringer & Bellringer::operator= ( const Bellringer )
privatedelete

◆ check()

void Bellringer::check ( )
static

Checks whether there are bells to be rung.

Every call to check elapses a tick. Once such a tick reduces a bells remaining time to zero, the bell will be rung.

Todo:
Implement Method

◆ job()

void Bellringer::job ( Bell bell,
unsigned int  ms 
)
static

Passes a bell to the bellringer to be rung after ms milliseconds.

Parameters
bellBell that should be rung after ms milliseconds
msnumber of milliseconds that should be waited before ringing the bell
Todo:
Implement Method

◆ cancel()

void Bellringer::cancel ( Bell bell)
static

Cancel ticking & ringing a bell.

Parameters
bellBell that should not be rung.
Todo:
Implement Method

◆ bellPending()

bool Bellringer::bellPending ( )
static

Checks whether there are enqueued bells.

Returns
true if there are enqueued bells, false otherwise
Todo:
Implement Method

Member Data Documentation

◆ bells

GlobalQueue< Bell > Bellringer::bells
staticprivate

List of bells currently managed.

This list contains non-expired bells enqueued by job(). These bells will be checked on every call to check().

All elements that should be inserted into a Queue instance are required to be derived from Queue<Bell>::Node.


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