RDMA++
Loading...
Searching...
No Matches
executor.h
1#pragma once
2
3#include <functional>
4#include <thread>
5#include <vector>
6
7#include <infiniband/verbs.h>
8
9#include "rdmapp/detail/blocking_queue.h"
10
11namespace rdmapp {
12
17class executor {
19 std::vector<std::thread> workers_;
20 work_queue work_queue_;
21 void worker_fn(size_t worker_id);
22
23public:
24 using queue_closed_error = work_queue::queue_closed_error;
25 using callback_fn = std::function<void(struct ibv_wc const &wc)>;
26 using callback_ptr = callback_fn *;
27
33 executor(size_t nr_worker = 4);
34
40 void process_wc(struct ibv_wc const &wc);
41
46 void shutdown();
47
48 ~executor();
49
58 template <class T> static callback_ptr make_callback(T const &cb) {
59 return new executor::callback_fn(cb);
60 }
61
67 static void destroy_callback(callback_ptr cb);
68};
69
70} // namespace rdmapp
This class is used to execute callbacks of completion entries.
Definition executor.h:17
void process_wc(struct ibv_wc const &wc)
Process a completion entry.
Definition executor.cc:27
static callback_ptr make_callback(T const &cb)
Make a callback function that will be called when a completion entry is processed....
Definition executor.h:58
void shutdown()
Shutdown the executor.
Definition executor.cc:29
static void destroy_callback(callback_ptr cb)
Destroy a callback function.
Definition executor.cc:31