10#include <l4/re/util/object_registry>
11#include <l4/re/util/br_manager>
12#include <l4/cxx/ipc_timeout_queue>
13#include <l4/cxx/ref_ptr>
15#include <l4/libblock-device/debug.h>
19namespace Block_device {
namespace Errand {
22extern L4::Ipc_svr::Server_iface *_sif;
27typedef std::function<void()> Callback;
54 Err().printf(
"Polling task failed: %s\n", e.
str());
68 template<
typename T,
typename... Args >
73 Poll_errand(
int retries,
int interval,
74 std::function<
bool()>
const &poll_func,
75 std::function<
void(
bool)>
const &callback)
84 std::function<bool()> _poll;
85 std::function<void(
bool)> _callback;
116 Err().printf(
"Asynchronous task failed: %s\n", e.
str());
121 void reschedule(
unsigned interval = 0)
130 template<
typename T,
typename... Args >
135 Errand(Callback
const &callback) : _callback(callback) {}
141: L4::Ipc_svr::Timeout_queue_hooks<Loop_hooks, L4Re::Util::Br_manager>,
142 L4::Ipc_svr::Ignore_errors
147using Errand_server = L4Re::Util::Registry_server<Loop_hooks>;
154inline void set_server_iface(L4::Ipc_svr::Server_iface *sif) { _sif = sif; }
166inline void schedule(Callback
const &callback,
int interval)
168 cxx::make_ref_obj<Errand>(callback)->reschedule(interval);
191inline void poll(
int retries,
int interval,
192 std::function<
bool()>
const &poll_func,
193 std::function<
void(
bool)>
const &callback)
198 cxx::make_ref_obj<Poll_errand>(retries, interval, poll_func,
199 callback)->reschedule();
void expired() final
callback function to be called when timeout happened
void expired() final
callback function to be called when timeout happened
L4::Ipc_svr::Timeout Timeout
Provide a local definition of Timeout for backward compatibility.
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.