Condy v1.3.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
context.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7#include "condy/singleton.hpp"
8#include <cassert>
9#include <cstdint>
10
11namespace condy {
12
13class Ring;
14class Runtime;
15class WorkInvoker;
16
17namespace detail {
18
19class Context : public ThreadLocalSingleton<Context> {
20public:
21 void init(Ring *ring, Runtime *runtime) {
22 ring_ = ring;
23 runtime_ = runtime;
24 next_bgid_ = 0;
25 }
26 void reset() {
27 ring_ = nullptr;
28 runtime_ = nullptr;
29 next_bgid_ = 0;
30 }
31
32 Ring *ring() { return ring_; }
33
34 Runtime *runtime() { return runtime_; }
35
36 uint16_t next_bgid() { return next_bgid_++; }
37
38private:
39 Ring *ring_ = nullptr;
40 Runtime *runtime_ = nullptr;
41 uint16_t next_bgid_ = 0;
42};
43
44} // namespace detail
45
46} // namespace condy
The event loop runtime for executing asynchronous.
Definition runtime.hpp:76
The main namespace for the Condy library.
Definition condy.hpp:28