Condy v1.1.0
C++ Asynchronous System Call Layer for Linux
Loading...
Searching...
No Matches
singleton.hpp
Go to the documentation of this file.
1
4
5#pragma once
6
7namespace condy {
8
9template <typename T> class ThreadLocalSingleton {
10public:
11 ThreadLocalSingleton() = default;
12 ThreadLocalSingleton(const ThreadLocalSingleton &) = delete;
13 ThreadLocalSingleton &operator=(const ThreadLocalSingleton &) = delete;
14 ThreadLocalSingleton(ThreadLocalSingleton &&) = delete;
15 ThreadLocalSingleton &operator=(ThreadLocalSingleton &&) = delete;
16
17 static T &current() {
18 static thread_local T instance;
19 return instance;
20 }
21};
22
23} // namespace condy
The main namespace for the Condy library.
Definition condy.hpp:28