LeechCraft 0.6.70-17609-g3dde4097dd
Modular cross-platform feature rich live environment.
Loading...
Searching...
No Matches
process.cpp
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#include "process.h"
10#include <QProcess>
11
12namespace LC::Util::detail
13{
14 bool ProcessAwaiter::await_ready () const noexcept
15 {
16 return Process_.state () == QProcess::NotRunning;
17 }
18
19 void ProcessAwaiter::await_suspend (std::coroutine_handle<> handle) noexcept
20 {
21 FinishedConn_ = QObject::connect (&Process_,
22 &QProcess::finished,
23 handle);
24 ErrorConn_ = QObject::connect (&Process_,
25 &QProcess::errorOccurred,
26 [this, handle]
27 {
28 if (await_ready ())
29 {
30 QObject::disconnect (std::move (FinishedConn_).Release ());
31 handle ();
32 }
33 });
34 }
35
36 void ProcessAwaiter::await_resume () const noexcept
37 {
38 }
39}
40
41namespace LC
42{
43 UTIL_THREADS_API Util::detail::ProcessAwaiter operator co_await (QProcess& reply)
44 {
45 return { reply };
46 }
47}
Definition constants.h:15
RaiiSignalConnection FinishedConn_
Definition process.h:24
void await_suspend(std::coroutine_handle<> handle) noexcept
Definition process.cpp:19
void await_resume() const noexcept
Definition process.cpp:36
RaiiSignalConnection ErrorConn_
Definition process.h:25
bool await_ready() const noexcept
Definition process.cpp:14
#define UTIL_THREADS_API