Condy v1.6.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
invoker.hpp
Go to the documentation of this file.
1
6
7#pragma once
8
9#include "condy/intrusive.hpp"
10
11namespace condy {
12
13class Invoker {
14public:
15 using Func = void (*)(void *) noexcept;
16 Invoker(Func func) : func_(func) {}
17
18 void operator()() noexcept { func_(this); }
19
20protected:
21 Func func_;
22};
23
24template <typename T, typename Invoker = Invoker>
25class InvokerAdapter : public Invoker {
26public:
27 InvokerAdapter() : Invoker(&InvokerAdapter::invoke_) {}
28
29private:
30 static void invoke_(void *self) noexcept {
31 static_cast<T *>(self)->invoke();
32 }
33};
34
35class WorkInvoker : public Invoker {
36public:
37 using Invoker::Invoker;
38 SingleLinkEntry work_queue_entry_;
39};
40
41} // namespace condy
Intrusive single-linked and double-linked list implementations.
The main namespace for the Condy library.
Definition condy.hpp:30