L4Re Operating System Framework
Interface and Usage Documentation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
poll_timeout_kipclock
1// vi:set ft=cpp: -*- Mode: C++ -*-
2/*
3 * (c) 2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
4 * economic rights: Technische Universität Dresden (Germany)
5 * License: see LICENSE.spdx (in this directory or the directories above)
6 */
7#pragma once
8
9#include <l4/sys/kip.h>
10#include <l4/re/env.h>
11
12namespace L4 {
13
36{
37public:
42 Poll_timeout_kipclock(unsigned poll_time_us)
43 {
44 set(poll_time_us);
45 }
46
51 void set(unsigned poll_time_us)
52 {
53 _timeout = l4_kip_clock(l4re_kip()) + poll_time_us;
54 _last_check = true;
55 }
56
65 bool test(bool expression = true)
66 {
67 if (!expression)
68 return false;
69
70 return _last_check = l4_kip_clock(l4re_kip()) < _timeout;
71 }
72
77 bool timed_out() const { return !_last_check; }
78
79private:
80 l4_cpu_time_t _timeout;
81 bool _last_check;
82};
83}
A polling timeout based on the L4Re clock.
Poll_timeout_kipclock(unsigned poll_time_us)
Initialise relative timeout in microseconds.
bool test(bool expression=true)
Test whether timeout has expired.
void set(unsigned poll_time_us)
(Re-)Set relative timeout in microseconds
bool timed_out() const
Query whether timeout has expired.
Environment interface.
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition env.h:184
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition l4int.h:47
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Definition kip.h:200
L4 low-level kernel interface.
Kernel Info Page access functions.