L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
L4::Poll_timeout_counter Class Reference

Evaluate an expression for a maximum number of times. More...

#include <poll_timeout_counter.h>

+ Collaboration diagram for L4::Poll_timeout_counter:

Public Member Functions

 Poll_timeout_counter (unsigned counter_val)
 Constructor.
 
void set (unsigned counter_val)
 Set the counter to a certain value.
 
bool test (bool expression=true)
 Evaluate the expression for a maximum number of times.
 
bool timed_out () const
 Indicator if the maximum number of tests was required.
 

Detailed Description

Evaluate an expression for a maximum number of times.

A typical use case is testing for a bit change in a hardware register for a maximum number of times (polling). For example:

{c++}
Mmio_register_block regs;
while (i.test(!(regs.read<l4_uint32_t>(0x04) & 1)))
;
Evaluate an expression for a maximum number of times.
unsigned int l4_uint32_t
Unsigned 32bit value.
Definition l4int.h:40

The following usage is wrong:

{c++}
...
Poll_timeout_counter i(3000000);
while (!i.test((regs.read<l4_uint32_t>(0x04) & 1)))
;

This loop would never terminate if the hardware register doesn't change!

Definition at line 36 of file poll_timeout_counter.h.

Constructor & Destructor Documentation

◆ Poll_timeout_counter()

L4::Poll_timeout_counter::Poll_timeout_counter ( unsigned  counter_val)
inline

Constructor.

Parameters
counter_valMaximum number of times to repeat the test.

Definition at line 44 of file poll_timeout_counter.h.

References set().

+ Here is the call graph for this function:

Member Function Documentation

◆ set()

void L4::Poll_timeout_counter::set ( unsigned  counter_val)
inline

Set the counter to a certain value.

Parameters
counter_valNew counter value for maximum number of times to repeat the test.

Definition at line 55 of file poll_timeout_counter.h.

Referenced by Poll_timeout_counter().

+ Here is the caller graph for this function:

◆ timed_out()

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

Indicator if the maximum number of tests was required.

Return values
true,ifthe maximum number of tests was required or if the counter was initialized to zero.

Definition at line 83 of file poll_timeout_counter.h.


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