Loading...
Searching...
No Matches
poll_timeout_kipclock
// vi:set ft=cpp: -*- Mode: C++ -*-
/*
* (c) 2012 Adam Lackorzynski <adam@os.inf.tu-dresden.de>,
* economic rights: Technische Universität Dresden (Germany)
* License: see LICENSE.spdx (in this directory or the directories above)
*/
#pragma once
#include <l4/sys/kip.h>
#include <l4/re/env.h>
namespace L4 {
class Poll_timeout_kipclock
{
public:
Poll_timeout_kipclock(unsigned poll_time_us)
{
set(poll_time_us);
}
void set(unsigned poll_time_us)
{
_timeout = l4_kip_clock(l4re_kip()) + poll_time_us;
_last_check = true;
}
bool test(bool expression = true)
{
if (!expression)
return false;
return _last_check = l4_kip_clock(l4re_kip()) < _timeout;
}
bool timed_out() const { return !_last_check; }
private:
l4_cpu_time_t _timeout;
bool _last_check;
};
}
L4::Poll_timeout_kipclock::Poll_timeout_kipclock
Poll_timeout_kipclock(unsigned poll_time_us)
Initialise relative timeout in microseconds.
Definition poll_timeout_kipclock:42
L4::Poll_timeout_kipclock::test
bool test(bool expression=true)
Test whether timeout has expired.
Definition poll_timeout_kipclock:65
L4::Poll_timeout_kipclock::set
void set(unsigned poll_time_us)
(Re-)Set relative timeout in microseconds
Definition poll_timeout_kipclock:51
L4::Poll_timeout_kipclock::timed_out
bool timed_out() const
Query whether timeout has expired.
Definition poll_timeout_kipclock:77
env.h
Environment interface.
l4re_kip
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
Definition env.h:185
l4_cpu_time_t
l4_uint64_t l4_cpu_time_t
CPU clock type.
Definition l4int.h:47
l4_kip_clock
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Definition kip.h:242
L4
L4 low-level kernel interface.
Definition l4sys-l4f-groups.dox:50
kip.h
Kernel Info Page access functions.