LeechCraft  0.6.70-18450-gabe19ee3b0
Modular cross-platform feature rich live environment.
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 
12 namespace LC::Util::detail
13 {
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 
37  {
38  }
39 }
40 
41 namespace LC
42 {
43  UTIL_THREADS_API Util::detail::ProcessAwaiter operator co_await (QProcess& reply)
44  {
45  return { reply };
46  }
47 }
void await_resume() const noexcept
Definition: process.cpp:36
#define UTIL_THREADS_API
Definition: threadsconfig.h:16
void await_suspend(std::coroutine_handle<> handle) noexcept
Definition: process.cpp:19
auto Tup2 &&tup2 noexcept
Definition: ctstringutils.h:68
bool await_ready() const noexcept
Definition: process.cpp:14