YACLib
C++ library for concurrent tasks execution
Loading...
Searching...
No Matches
fiber_base.hpp
Go to the documentation of this file.
1#pragma once
2
3#include <yaclib/config.hpp>
10
11#include <exception>
12#include <unordered_map>
13
14namespace yaclib::detail::fiber {
15
16class BiNodeScheduler : public Node {};
17
18class BiNodeWaitQueue : public Node {};
19
23 Waiting, // TODO(MBkkt) remove, looks useless
25};
26
28 public:
29 using Id = std::uint64_t;
30
31 FiberBase();
32
34
36
37 void Resume();
38
39 void Suspend();
40
42
44
46
48
49 void* GetTLS(std::uint64_t id, std::unordered_map<std::uint64_t, void*>& defaults);
50
51 void SetTLS(std::uint64_t id, void* value);
52
54
56
58 void Start();
59 void Exit();
60
63 std::exception_ptr _exception;
64
65 private:
66 ExecutionContext _caller_context{};
67 std::unordered_map<std::uint64_t, void*> _tls;
68 FiberBase* _joining_fiber = nullptr;
69 Id _id;
70 FiberState _state = Suspended;
71 bool _thread_alive = true;
72};
73
74} // namespace yaclib::detail::fiber
void SetState(FiberState state) noexcept
FiberState GetState() noexcept
bool IsThreadAlive() const noexcept
void SetJoiningFiber(FiberBase *joining_fiber) noexcept
void SetTLS(std::uint64_t id, void *value)
static IStackAllocator & GetAllocator() noexcept
void * GetTLS(std::uint64_t id, std::unordered_map< std::uint64_t, void * > &defaults)
Passed to coroutine/fiber constructor, specifies the way in which memory for Stack is Allocated and R...
Manages stack memory.
Definition stack.hpp:12
Contract< V, E > MakeContract()
Creates related future and promise.
Definition contract.hpp:25