LeechCraft 0.6.70-19214-g121e5318a7
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
corocontext.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 <list>
13#include <stdexcept>
14#include <vector>
15#include <QStringList>
16#include "../threadsconfig.h"
17
18class QObject;
19
20namespace LC::Util
21{
22 class UTIL_THREADS_API ContextDeadException : public std::runtime_error
23 {
24 public:
25 explicit ContextDeadException (const QString&);
26 };
27
29
30 namespace detail
31 {
32 struct PromiseBase;
33 }
34
36 {
37 friend struct AddContext;
38 friend struct ContextExtensionBase;
39
40 public:
41 struct Coro
42 {
43 std::coroutine_handle<> Handle_;
46 };
47 using Coros = std::list<Coro>;
48 private:
49 std::list<Coro> Coros_;
50 QString Name_;
51 public:
53 {
55 Coros::iterator Pos_;
56 };
57 using Registrations = std::vector<Registration>;
58
59 CoroContext () = default;
60 explicit CoroContext (const QString&);
61 explicit CoroContext (const QObject&);
62
63 CoroContext (const CoroContext&) = delete;
65 CoroContext& operator= (const CoroContext&) = delete;
66 CoroContext& operator= (CoroContext&&) = delete;
67
68 ~CoroContext ();
69
70 QString GetName () const { return Name_; }
71
83 static CoroContext& Of (QObject& obj);
84 };
85}
86
93#define LC_CORO_CONTEXT \
94 private: \
95 ::LC::Util::CoroContext CoroContext_ { *this };
ContextDeadException(const QString &)
std::list< Coro > Coros
Definition corocontext.h:47
friend struct ContextExtensionBase
Definition corocontext.h:38
friend struct AddContext
Definition corocontext.h:37
CoroContext(const CoroContext &)=delete
CoroContext(CoroContext &&)=delete
std::vector< Registration > Registrations
Definition corocontext.h:57
QString GetName() const
Definition corocontext.h:70
std::coroutine_handle Handle_
Definition corocontext.h:43
ContextExtensionBase * Promise_
Definition corocontext.h:45
detail::PromiseBase * Base_
Definition corocontext.h:44
#define UTIL_THREADS_API