Condy v1.7.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 "condy/utils.hpp"
9#include <cassert>
10#include <cstdint>
11
12namespace condy {
13
14class Ring;
15class Runtime;
16
17namespace detail {
18
19class Context : public ThreadLocalSingleton<Context> {
20public:
21 void init(Runtime *runtime) noexcept {
22 runtime_ = runtime;
23 bgid_pool_.reset();
24 }
25 void reset() noexcept {
26 runtime_ = nullptr;
27 bgid_pool_.reset();
28 }
29
30 Runtime *runtime() noexcept { return runtime_; }
31
32 uint16_t next_bgid() { return bgid_pool_.allocate(); }
33
34 void recycle_bgid(uint16_t bgid) noexcept { bgid_pool_.recycle(bgid); }
35
36private:
37 Runtime *runtime_ = nullptr;
38 IdPool<uint16_t> bgid_pool_;
39};
40
41} // namespace detail
42
43} // namespace condy
The event loop runtime for executing asynchronous.
Definition runtime.hpp:117
The main namespace for the Condy library.
Definition condy.hpp:31
Internal utility classes and functions used by Condy.