L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
poll_timeout_counter.h
1/*
2 * Copyright (C) 2012 Technische Universität Dresden.
3 * Author(s): Adam Lackorzynski <adam@os.inf.tu-dresden.de>
4 *
5 * License: see LICENSE.spdx (in this directory or the directories above)
6 */
7#pragma once
8
9namespace L4 {
10
35{
36public:
42 Poll_timeout_counter(unsigned counter_val)
43 {
44 set(counter_val);
45 }
46
53 void set(unsigned counter_val)
54 {
55 _c = counter_val;
56 }
57
61 bool test(bool expression = true)
62 {
63 if (!expression)
64 return false;
65
66 if (_c)
67 {
68 --_c;
69 return true;
70 }
71
72 return false;
73 }
74
81 bool timed_out() const { return _c == 0; }
82
83private:
84 unsigned _c;
85};
86
87}
Evaluate an expression for a maximum number of times.
void set(unsigned counter_val)
Set the counter to a certain value.
Poll_timeout_counter(unsigned counter_val)
Constructor.
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.
L4 low-level kernel interface.