libfilezilla
Toggle main menu visibility
Loading...
Searching...
No Matches
lib
libfilezilla
glue
async_pipe.hpp
1
#ifndef LIBFILEZILLA_GLUE_ASYNC_PIPE_HEADER
2
#define LIBFILEZILLA_GLUE_ASYNC_PIPE_HEADER
3
4
#include "
../libfilezilla.hpp
"
5
6
#ifdef FZ_WINDOWS
7
8
#include "
../buffer.hpp
"
9
#include "
../event.hpp
"
10
#include "
../fsresult.hpp
"
11
#include "
../thread_pool.hpp
"
12
13
#include "windows.hpp"
14
15
#include <optional>
16
17
namespace
fz
{
18
19
class
event_handler
;
20
21
26
enum class
pipe_event_flag
27
{
29
read
= 0x1,
30
32
write
= 0x2,
33
};
34
36
struct
pipe_event_type;
37
38
class
async_pipe;
39
53
typedef
simple_event<pipe_event_type, async_pipe*, pipe_event_flag>
pipe_event
;
54
55
56
class
FZ_PUBLIC_SYMBOL async_pipe final
57
{
58
public
:
59
// Connect a named pipe to a pipe server
60
async_pipe(
thread_pool
& pool,
event_handler
& h);
61
async_pipe(
thread_pool
& pool,
event_handler
& h, HANDLE read_pipe, HANDLE write_pipe);
62
async_pipe(
thread_pool
& pool,
event_handler
& h, std::wstring_view name);
63
~async_pipe();
64
65
async_pipe(async_pipe
const
&) =
delete
;
66
async_pipe& operator=(async_pipe
const
&) =
delete
;
67
68
bool
connect_named_pipe(std::wstring_view name);
69
70
bool
valid()
const
;
71
72
void
reset();
73
80
rwresult
read
(
void
*
buffer
,
size_t
len);
81
87
rwresult
write
(
void
const
*
buffer
,
size_t
len);
88
89
inline
rwresult
write
(std::string_view
const
& s) {
90
return
write
(s.data(), s.size());
91
}
92
93
private
:
94
bool
init();
95
void
thread_entry();
96
thread_pool
& pool_;
97
event_handler
& handler_;
98
99
mutex
mutex_{
false
};
100
async_task task_;
101
buffer read_buffer_;
102
buffer write_buffer_;
103
HANDLE sync_{INVALID_HANDLE_VALUE};
104
OVERLAPPED ol_read_{};
105
OVERLAPPED ol_write_{};
106
rwresult write_error_{0};
107
std::optional<rwresult> terminal_read_result_;
108
bool
waiting_read_{
true
};
109
bool
waiting_write_{};
110
bool
quit_{};
111
112
HANDLE read_{INVALID_HANDLE_VALUE};
113
HANDLE write_{INVALID_HANDLE_VALUE};
114
};
115
116
}
117
118
#else
119
#error This file is for Windows only
120
#endif
121
122
#endif
buffer.hpp
Declares fz::buffer.
fz::async_pipe::write
rwresult write(void const *buffer, size_t len)
Write data data process.
fz::async_pipe::read
rwresult read(void *buffer, size_t len)
Read data from process.
fz::buffer
Definition
buffer.hpp:200
fz::event_handler
Definition
event_handler.hpp:63
fz::mutex
Lean replacement for std::(recursive_)mutex.
Definition
mutex.hpp:75
fz::rwresult
Holds the result of read/write operations.
Definition
fsresult.hpp:80
fz::simple_event
This is the recommended event class.
Definition
event.hpp:68
fz::thread_pool
A dumb thread-pool for asynchronous tasks.
Definition
thread_pool.hpp:64
event.hpp
Declares event_base and simple_event<>.
fsresult.hpp
result and rwresult wrappers for dealing with file system errors.
libfilezilla.hpp
Sets some global macros and further includes string.hpp.
fz
The namespace used by libfilezilla.
Definition
apply.hpp:17
fz::pipe_event
simple_event< pipe_event_type, async_pipe *, pipe_event_flag > pipe_event
Definition
async_pipe.hpp:53
fz::pipe_event_flag
pipe_event_flag
The type of a pipe event.
Definition
async_pipe.hpp:27
fz::process_event_flag::read
@ read
Data has become available.
Definition
process.hpp:29
fz::process_event_flag::write
@ write
data can be written.
Definition
process.hpp:32
thread_pool.hpp
Declares thread_pool and async_task.
Generated by
1.17.0