L4Re - L4 Runtime Environment
L4::Poll_timeout_kipclock Class Reference

A polling timeout based on the L4Re clock. More...

+ Collaboration diagram for L4::Poll_timeout_kipclock:

Public Member Functions

 Poll_timeout_kipclock (unsigned poll_time_us)
 Initialise relative timeout in microseconds. More...
 
void set (unsigned poll_time_us)
 (Re-)Set relative timeout in microseconds More...
 
bool test (bool expression=true)
 Test whether timeout has expired. More...
 
bool timed_out () const
 Query whether timeout has expired. More...
 

Detailed Description

A polling timeout based on the L4Re clock.

This class allows to conveniently add a timeout to a polling loop.

The original

while (device.read(State) & Busy)
;

is converted to

Poll_timeout_kipclock timeout(10000);
while (timeout.test(device.read(State) & Busy))
;
if (timeout.timed_out())
printf("ERROR: Device does not respond.\n");

Definition at line 37 of file poll_timeout_kipclock.

Constructor & Destructor Documentation

◆ Poll_timeout_kipclock()

L4::Poll_timeout_kipclock::Poll_timeout_kipclock ( unsigned  poll_time_us)
inline

Initialise relative timeout in microseconds.

Parameters
poll_time_usPolling timeout in microseconds.

Definition at line 44 of file poll_timeout_kipclock.

Member Function Documentation

◆ set()

void L4::Poll_timeout_kipclock::set ( unsigned  poll_time_us)
inline

(Re-)Set relative timeout in microseconds

Parameters
poll_time_usPolling timeout in microseconds.

Definition at line 53 of file poll_timeout_kipclock.

◆ test()

bool L4::Poll_timeout_kipclock::test ( bool  expression = true)
inline

Test whether timeout has expired.

Parameters
expressionOptional expression.
Return values
falseThe timeout has expired or the given expression returned false.
trueThe timeout has not expired and the optionally given expression returns true.

Definition at line 67 of file poll_timeout_kipclock.

◆ timed_out()

bool L4::Poll_timeout_kipclock::timed_out ( ) const
inline

Query whether timeout has expired.

Returns
Expiry state of timeout

Definition at line 79 of file poll_timeout_kipclock.


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