Condy v1.1.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
17class Context : public ThreadLocalSingleton<Context> {
18public:
19 void init(Ring *ring, Runtime *runtime) {
20 ring_ = ring;
21 runtime_ = runtime;
22 next_bgid_ = 0;
23 cred_id_ = 0;
24 }
25 void reset() {
26 ring_ = nullptr;
27 runtime_ = nullptr;
28 next_bgid_ = 0;
29 cred_id_ = 0;
30 }
31
32 Ring *ring() { return ring_; }
33
34 Runtime *runtime() { return runtime_; }
35
36 uint16_t next_bgid() { return next_bgid_++; }
37
38 void set_cred_id(uint16_t id) { cred_id_ = id; }
39 uint16_t cred_id() { return cred_id_; }
40
41private:
42 Ring *ring_ = nullptr;
43 Runtime *runtime_ = nullptr;
44 uint16_t next_bgid_ = 0;
45 uint16_t cred_id_ = 0;
46};
47
48} // namespace condy
The event loop runtime for executing asynchronous.
Definition runtime.hpp:76
The main namespace for the Condy library.
Definition condy.hpp:28