YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
thread_local_proxy.cpp
Go to the documentation of this file.
4
5#include <unordered_map>
6
7namespace yaclib::detail::fiber {
8
9static auto& GetMap() {
10 static std::unordered_map<std::uint64_t, void*> sDefaults;
11 return sDefaults;
12}
13
14void* GetImpl(std::uint64_t i) {
15 auto* fiber = fault::Scheduler::Current();
16 YACLIB_ASSERT(fiber);
17 return fiber->GetTLS(i, GetMap());
18}
19
20void Set(void* new_value, std::uint64_t i) {
21 auto* fiber = fault::Scheduler::Current();
22 YACLIB_ASSERT(fiber);
23 fiber->SetTLS(i, new_value);
24}
25
26void SetDefault(void* new_value, std::uint64_t i) {
27 GetMap()[i] = new_value;
28}
29
30} // namespace yaclib::detail::fiber
static detail::fiber::FiberBase * Current() noexcept
Definition scheduler.cpp:48
#define YACLIB_ASSERT(cond)
Definition log.hpp:85
void SetDefault(void *new_value, std::uint64_t i)
void * GetImpl(std::uint64_t i)
void Set(void *new_value, std::uint64_t i)
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25