LeechCraft 0.6.70-19214-g121e5318a7
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
process.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 <variant>
13#include <QObject>
14#include <QString>
16#include "../threadsconfig.h"
17#include "taskfwd.h"
18
19class QDebug;
20class QProcess;
21
22namespace LC::Util
23{
25 {
26 QString Error_;
27
28 auto operator<=> (const ProcessFailedToStart&) const = default;
29 };
30
32 {
33 int Code_;
34
35 auto operator<=> (const ProcessCrashed&) const = default;
36 };
37
39 {
40 int Code_;
41
42 auto operator<=> (const ProcessExited&) const = default;
43 };
44
45 using ProcessOutcome = std::variant<ProcessFailedToStart, ProcessCrashed, ProcessExited>;
46
48 UTIL_THREADS_API QDebug operator<< (QDebug, const ProcessCrashed&);
49 UTIL_THREADS_API QDebug operator<< (QDebug, const ProcessExited&);
50 UTIL_THREADS_API QDebug operator<< (QDebug, const ProcessOutcome&);
51
52 namespace detail
53 {
55 {
56 QProcess& Process_;
57
58 QObject CoroResumeGuard_ {};
59
62
63 bool await_ready () const noexcept;
64 void await_suspend (std::coroutine_handle<> handle);
65 ProcessOutcome await_resume () const;
66 };
67 }
68
69 inline detail::ProcessAwaiter GetAwaiter (QProcess& process, AwaiterCPO)
70 {
71 return detail::ProcessAwaiter { process };
72 }
73}
74
75namespace LC
76{
77 inline auto operator co_await (QProcess& process)
78 {
79 return Util::GetAwaiter (process, {});
80 }
81}
std::variant< ProcessFailedToStart, ProcessCrashed, ProcessExited > ProcessOutcome
Definition process.h:45
detail::EitherAwaiter< L, R, std::identity > GetAwaiter(const Either< L, R > &either, AwaiterCPO)
Definition either.h:119
QDebug operator<<(QDebug dbg, const CtString< N, Char > &str)
Definition constants.h:15
auto operator<=>(const ProcessCrashed &) const =default
auto operator<=>(const ProcessExited &) const =default
auto operator<=>(const ProcessFailedToStart &) const =default
RaiiSignalConnection FinishedConn_
Definition process.h:60
RaiiSignalConnection ErrorConn_
Definition process.h:61
#define UTIL_THREADS_API