LeechCraft 0.6.70-18808-g3467692359
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
sharedtask.h
Go to the documentation of this file.
1/**********************************************************************
2 * LeechCraft - modular cross-platform feature rich internet client.
3 * Copyright (C) 2006-2014 Georg Rudoy
4 *
5 * Distributed under the Boost Software License, Version 1.0.
6 * (See accompanying file LICENSE or copy at https://www.boost.org/LICENSE_1_0.txt)
7 **********************************************************************/
8
9#pragma once
10
11#include <coroutine>
12#include <QList>
13#include <QtDebug>
14#include "task.h"
15#include "context.h"
16
17namespace LC::Util
18{
19 template<typename>
21 {
22 static constexpr bool IsAwaiterHandler = true;
23 static constexpr bool IsResumeValueHandler = true;
24
26
27 void AddAwaiter (std::coroutine_handle<> outerTask)
28 {
29 Awaiters_ << outerTask;
30 }
31
32 void RemoveAwaiter (std::coroutine_handle<> outerTask) noexcept
33 {
34 if (!Awaiters_.removeOne (outerTask))
35 qFatal () << "awaiter not found";
36 }
37
39 {
40 return this->Awaiters_;
41 }
42
43 template<typename R>
44 static const R& ResumeValue (R& ret) noexcept
45 {
46 return ret;
47 }
48 };
49
50 template<typename T = void>
52
53 template<typename T = void>
55}
Task< T, SharedTaskExtension > SharedTask
Definition sharedtask.h:51
Task< T, SharedTaskExtension, ContextExtension > SharedContextTask
Definition sharedtask.h:54
QList< std::coroutine_handle<> > Awaiters_
Definition sharedtask.h:25
static constexpr bool IsAwaiterHandler
Definition sharedtask.h:22
static const R & ResumeValue(R &ret) noexcept
Definition sharedtask.h:44
void RemoveAwaiter(std::coroutine_handle<> outerTask) noexcept
Definition sharedtask.h:32
static constexpr bool IsResumeValueHandler
Definition sharedtask.h:23
void AddAwaiter(std::coroutine_handle<> outerTask)
Definition sharedtask.h:27