userver: userver/engine/subprocess/child_process.hpp Source File
Loading...
Searching...
No Matches
child_process.hpp
Go to the documentation of this file.
1#pragma once
2
5
6#include <chrono>
7
12
13USERVER_NAMESPACE_BEGIN
14
15namespace engine::subprocess {
16
17class ChildProcessImpl;
18
20class ChildProcess final {
21public:
23 explicit ChildProcess(ChildProcessImpl&& impl) noexcept;
25
26 ChildProcess(ChildProcess&&) noexcept;
27 ChildProcess& operator=(ChildProcess&&) noexcept;
28
31
33 int GetPid() const;
34
37 void Wait();
38
42 template <typename Rep, typename Period>
43 [[nodiscard]] bool WaitFor(std::chrono::duration<Rep, Period> duration) {
44 return WaitUntil(Deadline::FromDuration(duration));
45 }
46
49 // happened; true otherwise.
50 template <typename Clock, typename Duration>
51 [[nodiscard]] bool WaitUntil(std::chrono::time_point<Clock, Duration> until) {
53 }
54
58 [[nodiscard]] bool WaitUntil(Deadline deadline);
59
62 [[nodiscard]] ChildProcessStatus Get();
63
65 void SendSignal(int signum);
66
67private:
68 static constexpr std::size_t kImplSize = compiler::SelectSize().For64Bit(24).For32Bit(12);
69 static constexpr std::size_t kImplAlignment = alignof(void*);
71};
72
73} // namespace engine::subprocess
74
75USERVER_NAMESPACE_END