genode/repos/base/src/timer/include/signalled_time_source.h
Norman Feske bf62d6b896 Move timer from os to base repository
Since the timer and timeout handling is part of the base library (the
dynamic linker), it belongs to the base repository.

Besides moving the timer and its related infrastructure (alarm, timeout
libs, tests) to the base repository, this patch also moves the timer
from the 'drivers' subdirectory directly to 'src' and disamibuates the
timer's build locations for the various kernels. Otherwise the different
timer implementations could interfere with each other when using one
build directory with multiple kernels.

Note that this patch changes the include paths for the former os/timer,
os/alarm.h, os/duration.h, and os/timed_semaphore.h to base/.

Issue #3101
2019-01-14 12:33:57 +01:00

63 lines
1.3 KiB
C++

/*
* \brief Time source that handles timeouts via a signal handler
* \author Martin Stein
* \date 2016-11-04
*/
/*
* Copyright (C) 2016-2017 Genode Labs GmbH
*
* This file is part of the Genode OS framework, which is distributed
* under the terms of the GNU Affero General Public License version 3.
*/
#ifndef _SIGNALLED_TIME_SOURCE_H_
#define _SIGNALLED_TIME_SOURCE_H_
/* Genode includes */
#include <base/env.h>
#include <timer/timeout.h>
#include <base/rpc_client.h>
namespace Genode { class Signalled_time_source; }
class Genode::Signalled_time_source : public Time_source
{
private:
/*
* Noncopyable
*/
Signalled_time_source(Signalled_time_source const &);
Signalled_time_source &operator = (Signalled_time_source const &);
protected:
using Signal_handler = Genode::Signal_handler<Signalled_time_source>;
Signal_handler _signal_handler;
Timeout_handler *_handler = nullptr;
bool _irq = false;
void _handle_timeout()
{
if (_handler) {
_irq = true;
Duration time(curr_time());
_irq = false;
_handler->handle_timeout(time);
}
}
public:
Signalled_time_source(Env &env)
:
_signal_handler(env.ep(), *this,
&Signalled_time_source::_handle_timeout)
{ }
};
#endif /* _SIGNALLED_TIME_SOURCE_H_ */