L4Re Operating System Framework
Interface and Usage Documentation
Loading...
Searching...
No Matches
poll_timeout_counter.h
1/*
2 * (c) 2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>
3 * economic rights: Technische Universität Dresden (Germany)
4 *
5 * This file is part of TUD:OS and distributed under the terms of the
6 * GNU General Public License 2.
7 * Please see the COPYING-GPL-2 file for details.
8 */
9#pragma once
10
11namespace L4 {
12
37{
38public:
44 Poll_timeout_counter(unsigned counter_val)
45 {
46 set(counter_val);
47 }
48
55 void set(unsigned counter_val)
56 {
57 _c = counter_val;
58 }
59
63 bool test(bool expression = true)
64 {
65 if (!expression)
66 return false;
67
68 if (_c)
69 {
70 --_c;
71 return true;
72 }
73
74 return false;
75 }
76
83 bool timed_out() const { return _c == 0; }
84
85private:
86 unsigned _c;
87};
88
89}
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.
Definition io_regblock.h:19