-
Notifications
You must be signed in to change notification settings - Fork 0
/
awaiter_fiber.h
44 lines (30 loc) · 994 Bytes
/
awaiter_fiber.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
//
// Created by konstantin on 06.06.24.
//
#pragma once
#include <context/buffer/buffer.h>
#include <coro/stackfull_coro.h>
#include <executor/executor.h>
#include <executor/task/task_base.h>
namespace NFibers {
class IAwaiter;
class AwaiterFiber final : public NExecutors::TaskBase {
public:
AwaiterFiber(NExecutors::IExecutor* executor, NCoro::Routine routine,
NContext::Buffer&& buffer);
AwaiterFiber(const AwaiterFiber&) = delete;
AwaiterFiber(AwaiterFiber&&) noexcept = delete;
AwaiterFiber& operator=(const AwaiterFiber&) = delete;
AwaiterFiber& operator=(AwaiterFiber&&) noexcept = delete;
void Schedule();
void Suspend(IAwaiter* waiter);
void Switch();
TaskRunResult Run() noexcept override;
static AwaiterFiber* Self();
NExecutors::IExecutor* GetScheduler();
private:
NExecutors::IExecutor* executor_;
NCoro::StackfullCoroutine fiber_coro_;
IAwaiter* awaiter_{nullptr};
};
} // namespace NFibers