YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
thread.hpp
Go to the documentation of this file.
1#pragma once
2
6#include <yaclib/log.hpp>
7
8#include <functional>
9#include <thread>
10
11namespace yaclib::detail::fiber {
12
13class Thread {
14 public:
15 Thread(const Thread&) = delete;
16 Thread& operator=(const Thread&) = delete;
17
19 using native_handle_type = void*;
20
21 template <typename... Args>
22 explicit Thread(Args&&... args) : _impl{new Fiber<Args...>(std::forward<Args>(args)...)} {
24 }
25
29 ~Thread();
30
31 void swap(Thread& t) noexcept;
33 void join();
34 void detach();
35
37
39
41
43
44 private:
45 void AfterJoinOrDetach();
46
47 FiberBase* _impl{nullptr};
48};
49
50} // namespace yaclib::detail::fiber
id get_id() const noexcept
Definition thread.cpp:48
native_handle_type native_handle() noexcept
Definition thread.cpp:52
static unsigned int hardware_concurrency() noexcept
Definition thread.cpp:57
Thread(const Thread &)=delete
void swap(Thread &t) noexcept
Definition thread.cpp:14
bool joinable() const noexcept
Definition thread.cpp:18
Thread(Args &&... args)
Definition thread.hpp:22
Thread & operator=(const Thread &)=delete
static void SetHardwareConcurrency(unsigned int hardware_concurrency) noexcept
Definition thread.cpp:85
void Schedule(detail::fiber::FiberBase *fiber)
Definition scheduler.cpp:38
static Scheduler * GetScheduler() noexcept
Definition scheduler.cpp:30
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25