CHERIoT RTOS
A compartmentalised RTOS for CHERIoT hardware
Loading...
Searching...
No Matches
Timeout Struct Reference

Structure representing a timeout. More...

#include <timeout.h>

Public Member Functions

 Timeout (Ticks time)
 Constructor, initialises this structure to allow time ticks to elapse.
 Timeout (Ticks elapsed, Ticks remaining)
 Constructor that initialises both fields, should be used only for initialiser-list initialisation in code that needs to compile as both C and C++.
void elapse (Ticks time)
 Update this timeout if time ticks have elapsed.
bool may_block ()
 Helper indicating whether the owner of this timeout may block.

Public Attributes

Ticks elapsed
 The time that has elapsed during blocking operations for this timeout structure.
Ticks remaining
 The remaining time.

Detailed Description

Structure representing a timeout.

This is intended to allow a single instance to be chained across blocking calls.

Timeouts may not be stored in the heap. Handling timeout structures that may disappear between sleeping and waking is very complicated and would impact a lot of fast paths. Instead, most functions that take a timeout will simply fail if the timeout is on the heap.

Definition at line 46 of file timeout.h.

Constructor & Destructor Documentation

◆ Timeout() [1/2]

Timeout::Timeout ( Ticks time)
inline

Constructor, initialises this structure to allow time ticks to elapse.

Definition at line 66 of file timeout.h.

References remaining.

◆ Timeout() [2/2]

Timeout::Timeout ( Ticks elapsed,
Ticks remaining )
inline

Constructor that initialises both fields, should be used only for initialiser-list initialisation in code that needs to compile as both C and C++.

Definition at line 73 of file timeout.h.

References elapsed, and remaining.

Member Function Documentation

◆ elapse()

void Timeout::elapse ( Ticks time)
inline

Update this timeout if time ticks have elapsed.

This function saturates the values on overflow.

Definition at line 82 of file timeout.h.

References elapsed, remaining, and UnlimitedTimeout.

◆ may_block()

bool Timeout::may_block ( )
inline

Helper indicating whether the owner of this timeout may block.

Definition at line 98 of file timeout.h.

References remaining.

Member Data Documentation

◆ elapsed

Ticks Timeout::elapsed

The time that has elapsed during blocking operations for this timeout structure.

This should be initialised to 0. It may exceed the initial value of remaining if a higher-priority thread preempts the blocking thread.

Definition at line 54 of file timeout.h.

Referenced by elapse(), and Timeout().

◆ remaining

Ticks Timeout::remaining

The remaining time.

This is clamped at 0 on subtraction. A special value of UnlimitedTimeout can be set to represent an unlimited timeout.

Definition at line 60 of file timeout.h.

Referenced by elapse(), may_block(), Timeout(), and Timeout().


The documentation for this struct was generated from the following file: