20#include <l4/re/util/object_registry>
21#include <l4/re/util/br_manager>
22#include <l4/cxx/ipc_timeout_queue>
23#include <l4/cxx/ref_ptr>
25#include <l4/libblock-device/debug.h>
29namespace Block_device {
namespace Errand {
37typedef std::function<void()> Callback;
64 Err().printf(
"Polling task failed: %s\n", e.
str());
78 template<
typename T,
typename... Args >
83 Poll_errand(
int retries,
int interval,
84 std::function<
bool()>
const &poll_func,
85 std::function<
void(
bool)>
const &callback)
94 std::function<bool()> _poll;
95 std::function<void(
bool)> _callback;
126 Err().printf(
"Asynchronous task failed: %s\n", e.
str());
131 void reschedule(
unsigned interval = 0)
140 template<
typename T,
typename... Args >
145 Errand(Callback
const &callback) : _callback(callback) {}
176inline void schedule(Callback
const &callback,
int interval)
178 cxx::make_ref_obj<Errand>(callback)->reschedule(interval);
201inline void poll(
int retries,
int interval,
202 std::function<
bool()>
const &poll_func,
203 std::function<
void(
bool)>
const &callback)
208 cxx::make_ref_obj<Poll_errand>(retries, interval, poll_func,
209 callback)->reschedule();
Wrapper for a small task executed asynchronously in the server loop.
void expired() final
callback function to be called when timeout happened
Wrapper for a regularly repeated task.
void expired() final
callback function to be called when timeout happened
A server loop object which has a Object_registry included.
Interface for server-loop related functions.
virtual int add_timeout(Timeout *timeout, l4_kernel_clock_t time)=0
Add a timeout to the server internal timeout queue.
Loop hooks mixin for integrating a timeout queue into the server loop.
Callback interface for Timeout_queue.
Exception for an abstract runtime error.
char const * str() const noexcept override
Return a human readable string for the exception.
A reference-counting pointer with automatic cleanup.
l4_kernel_info_t const * l4re_kip(void) L4_NOTHROW
Get Kernel Info Page.
l4_uint64_t l4_kernel_clock_t
Kernel clock type.
l4_cpu_time_t l4_kip_clock(l4_kernel_info_t const *kip) L4_NOTHROW
Return clock value from the KIP.
Mix in for LOOP_HOOKS to ignore IPC errors.