Skip to content

Commit 1bbdde8

Browse files
reduced asio related macro usage.
1 parent e0158d8 commit 1bbdde8

19 files changed

Lines changed: 238 additions & 234 deletions

include/boost/process/v2/bind_launcher.hpp

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ struct bound_launcher
7171
template<typename ExecutionContext, typename Args, typename ... Inits>
7272
auto operator()(ExecutionContext & context,
7373
const typename std::enable_if<std::is_convertible<
74-
ExecutionContext&, BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context&>::value,
74+
ExecutionContext&, net::execution_context&>::value,
7575
filesystem::path >::type & executable,
7676
Args && args,
7777
Inits && ... inits) -> basic_process<typename ExecutionContext::executor_type>
@@ -88,7 +88,7 @@ struct bound_launcher
8888
auto operator()(ExecutionContext & context,
8989
error_code & ec,
9090
const typename std::enable_if<std::is_convertible<
91-
ExecutionContext&, BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context&>::value,
91+
ExecutionContext&, net::execution_context&>::value,
9292
filesystem::path >::type & executable,
9393
Args && args,
9494
Inits && ... inits ) -> basic_process<typename ExecutionContext::executor_type>
@@ -103,8 +103,8 @@ struct bound_launcher
103103
template<typename Executor, typename Args, typename ... Inits>
104104
auto operator()(Executor exec,
105105
const typename std::enable_if<
106-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution::is_executor<Executor>::value ||
107-
BOOST_PROCESS_V2_ASIO_NAMESPACE::is_executor<Executor>::value,
106+
net::execution::is_executor<Executor>::value ||
107+
net::is_executor<Executor>::value,
108108
filesystem::path >::type & executable,
109109
Args && args,
110110
Inits && ... inits ) -> basic_process<Executor>
@@ -120,8 +120,8 @@ struct bound_launcher
120120
auto operator()(Executor exec,
121121
error_code & ec,
122122
const typename std::enable_if<
123-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution::is_executor<Executor>::value ||
124-
BOOST_PROCESS_V2_ASIO_NAMESPACE::is_executor<Executor>::value,
123+
net::execution::is_executor<Executor>::value ||
124+
net::is_executor<Executor>::value,
125125
filesystem::path >::type & executable,
126126
Args && args,
127127
Inits && ... inits ) -> basic_process<Executor>
@@ -138,7 +138,7 @@ struct bound_launcher
138138
auto invoke(detail::index_sequence<Idx...>,
139139
ExecutionContext & context,
140140
const typename std::enable_if<std::is_convertible<
141-
ExecutionContext&, BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context&>::value,
141+
ExecutionContext&, net::execution_context&>::value,
142142
filesystem::path >::type & executable,
143143
Args && args,
144144
Inits && ... inits) -> basic_process<typename ExecutionContext::executor_type>
@@ -156,7 +156,7 @@ struct bound_launcher
156156
ExecutionContext & context,
157157
error_code & ec,
158158
const typename std::enable_if<std::is_convertible<
159-
ExecutionContext&, BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context&>::value,
159+
ExecutionContext&, net::execution_context&>::value,
160160
filesystem::path >::type & executable,
161161
Args && args,
162162
Inits && ... inits ) -> basic_process<typename ExecutionContext::executor_type>
@@ -172,8 +172,8 @@ struct bound_launcher
172172
auto invoke(detail::index_sequence<Idx...>,
173173
Executor exec,
174174
const typename std::enable_if<
175-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution::is_executor<Executor>::value ||
176-
BOOST_PROCESS_V2_ASIO_NAMESPACE::is_executor<Executor>::value,
175+
net::execution::is_executor<Executor>::value ||
176+
net::is_executor<Executor>::value,
177177
filesystem::path >::type & executable,
178178
Args && args,
179179
Inits && ... inits ) -> basic_process<Executor>
@@ -190,8 +190,8 @@ struct bound_launcher
190190
Executor exec,
191191
error_code & ec,
192192
const typename std::enable_if<
193-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution::is_executor<Executor>::value ||
194-
BOOST_PROCESS_V2_ASIO_NAMESPACE::is_executor<Executor>::value,
193+
net::execution::is_executor<Executor>::value ||
194+
net::is_executor<Executor>::value,
195195
filesystem::path >::type & executable,
196196
Args && args,
197197
Inits && ... inits ) -> basic_process<Executor>

include/boost/process/v2/detail/config.hpp

Lines changed: 11 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,8 @@
77

88
#if defined(BOOST_PROCESS_V2_STANDALONE)
99

10-
#define BOOST_PROCESS_V2_ASIO_NAMESPACE asio
10+
1111
#define BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(Sig) ASIO_COMPLETION_TOKEN_FOR(Sig)
12-
#define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN_TYPE(Executor) ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)
13-
#define BOOST_PROCESS_V2_INITFN_AUTO_RESULT_TYPE(Token, Signature) ASIO_INITFN_AUTO_RESULT_TYPE(Token, Signature)
14-
#define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN(Executor) ASIO_DEFAULT_COMPLETION_TOKEN(Executor)
15-
#define BOOST_PROCESS_V2_INITFN_DEDUCED_RESULT_TYPE(x,y,z) ASIO_INITFN_DEDUCED_RESULT_TYPE(x,y,z)
1612

1713
#include <asio/detail/config.hpp>
1814
#include <system_error>
@@ -38,14 +34,14 @@
3834
#define BOOST_PROCESS_V2_END_NAMESPACE }
3935
#define BOOST_PROCESS_V2_NAMESPACE process_v2
4036

37+
namespace asio {}
38+
BOOST_PROCESS_V2_BEGIN_NAMESPACE
39+
namespace net = ::asio;
40+
BOOST_PROCESS_V2_END_NAMESPACE
41+
4142
#else
4243

43-
#define BOOST_PROCESS_V2_ASIO_NAMESPACE boost::asio
4444
#define BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(Sig) BOOST_ASIO_COMPLETION_TOKEN_FOR(Sig)
45-
#define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN_TYPE(Executor) BOOST_ASIO_DEFAULT_COMPLETION_TOKEN_TYPE(Executor)
46-
#define BOOST_PROCESS_V2_INITFN_AUTO_RESULT_TYPE(Token, Signature) BOOST_ASIO_INITFN_AUTO_RESULT_TYPE(Token, Signature)
47-
#define BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN(Executor) BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(Executor)
48-
#define BOOST_PROCESS_V2_INITFN_DEDUCED_RESULT_TYPE(x,y,z) BOOST_ASIO_INITFN_DEDUCED_RESULT_TYPE(x,y,z)
4945

5046
#include <boost/config.hpp>
5147
#include <boost/io/quoted.hpp>
@@ -94,6 +90,11 @@
9490
#define BOOST_PROCESS_V2_END_NAMESPACE } } }
9591
#define BOOST_PROCESS_V2_NAMESPACE boost::process::v2
9692

93+
namespace boost { namespace asio {} }
94+
BOOST_PROCESS_V2_BEGIN_NAMESPACE
95+
namespace net = ::boost::asio;
96+
BOOST_PROCESS_V2_END_NAMESPACE
97+
9798
#endif
9899

99100
BOOST_PROCESS_V2_BEGIN_NAMESPACE

include/boost/process/v2/detail/process_handle_fd.hpp

Lines changed: 19 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ BOOST_PROCESS_V2_BEGIN_NAMESPACE
3434
namespace detail
3535
{
3636

37-
template<typename Executor = BOOST_PROCESS_V2_ASIO_NAMESPACE::any_io_executor>
37+
template<typename Executor = net::any_io_executor>
3838
struct basic_process_handle_fd
3939
{
4040
using native_handle_type = int;
@@ -56,7 +56,7 @@ struct basic_process_handle_fd
5656
basic_process_handle_fd(ExecutionContext &context,
5757
typename std::enable_if<
5858
std::is_convertible<ExecutionContext &,
59-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context &>::value>::type * = nullptr)
59+
net::execution_context &>::value>::type * = nullptr)
6060
: pid_(-1), descriptor_(context)
6161
{
6262
}
@@ -275,25 +275,16 @@ struct basic_process_handle_fd
275275
return pid_ != -1;
276276
}
277277

278-
template<BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void(error_code, native_exit_code_type))
279-
WaitHandler BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
280-
BOOST_PROCESS_V2_INITFN_AUTO_RESULT_TYPE(WaitHandler, void (error_code, native_exit_code_type))
281-
async_wait(WaitHandler &&handler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
282-
{
283-
return BOOST_PROCESS_V2_ASIO_NAMESPACE::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
284-
async_wait_op_{descriptor_, pid_}, handler, descriptor_);
285-
}
286-
287278
private:
288279
template<typename>
289280
friend
290281
struct basic_process_handle_fd;
291282
pid_type pid_ = -1;
292-
BOOST_PROCESS_V2_ASIO_NAMESPACE::posix::basic_stream_descriptor<Executor> descriptor_;
283+
net::posix::basic_stream_descriptor<Executor> descriptor_;
293284

294285
struct async_wait_op_
295286
{
296-
BOOST_PROCESS_V2_ASIO_NAMESPACE::posix::basic_descriptor<Executor> &descriptor;
287+
net::posix::basic_descriptor<Executor> &descriptor;
297288
pid_type pid_;
298289

299290
template<typename Self>
@@ -304,7 +295,7 @@ struct basic_process_handle_fd
304295
native_exit_code_type exit_code{};
305296
int wait_res = -1;
306297
if (pid_ <= 0) // error, complete early
307-
ec = BOOST_PROCESS_V2_ASIO_NAMESPACE::error::bad_descriptor;
298+
ec = net::error::bad_descriptor;
308299
else
309300
{
310301
wait_res = ::waitpid(pid_, &exit_code, WNOHANG);
@@ -315,8 +306,7 @@ struct basic_process_handle_fd
315306

316307
if (!ec && (wait_res == 0))
317308
{
318-
descriptor.async_wait(
319-
BOOST_PROCESS_V2_ASIO_NAMESPACE::posix::descriptor_base::wait_read, std::move(self));
309+
descriptor.async_wait(net::posix::descriptor_base::wait_read, std::move(self));
320310
return;
321311
}
322312

@@ -331,8 +321,7 @@ struct basic_process_handle_fd
331321
self.complete(ec, code);
332322
}
333323
};
334-
BOOST_PROCESS_V2_ASIO_NAMESPACE::post(descriptor.get_executor(),
335-
completer{ec, exit_code, std::move(self)});
324+
net::post(descriptor.get_executor(), completer{ec, exit_code, std::move(self)});
336325

337326
}
338327

@@ -346,6 +335,18 @@ struct basic_process_handle_fd
346335
std::move(self).complete(ec, exit_code);
347336
}
348337
};
338+
public:
339+
340+
template<BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void(error_code, native_exit_code_type))
341+
WaitHandler = net::default_completion_token_t<executor_type>>
342+
auto async_wait(WaitHandler &&handler = net::default_completion_token_t<executor_type>())
343+
-> decltype(net::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
344+
async_wait_op_{descriptor_, pid_}, handler, descriptor_))
345+
{
346+
return net::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
347+
async_wait_op_{descriptor_, pid_}, handler, descriptor_);
348+
}
349+
349350
};
350351
}
351352

include/boost/process/v2/detail/process_handle_fd_or_signal.hpp

Lines changed: 23 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ BOOST_PROCESS_V2_BEGIN_NAMESPACE
3737
namespace detail
3838
{
3939

40-
template<typename Executor = BOOST_PROCESS_V2_ASIO_NAMESPACE::any_io_executor>
40+
template<typename Executor = net::any_io_executor>
4141
struct basic_process_handle_fd_or_signal
4242
{
4343
using native_handle_type = int;
@@ -59,7 +59,7 @@ struct basic_process_handle_fd_or_signal
5959
basic_process_handle_fd_or_signal(ExecutionContext &context,
6060
typename std::enable_if<
6161
std::is_convertible<ExecutionContext &,
62-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context &>::value
62+
net::execution_context &>::value
6363
>::type * = nullptr)
6464
: pid_(-1), descriptor_(context)
6565
{
@@ -70,7 +70,7 @@ struct basic_process_handle_fd_or_signal
7070
pid_type pid,
7171
typename std::enable_if<
7272
std::is_convertible<ExecutionContext &,
73-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context &>::value
73+
net::execution_context &>::value
7474
>::type * = nullptr)
7575
: pid_(pid), descriptor_(context)
7676
{
@@ -81,7 +81,7 @@ struct basic_process_handle_fd_or_signal
8181
pid_type pid, native_handle_type process_handle,
8282
typename std::enable_if<
8383
std::is_convertible<ExecutionContext &,
84-
BOOST_PROCESS_V2_ASIO_NAMESPACE::execution_context &>::value
84+
net::execution_context &>::value
8585
>::type * = nullptr)
8686
: pid_(pid), descriptor_(context, process_handle)
8787
{
@@ -305,31 +305,22 @@ struct basic_process_handle_fd_or_signal
305305
return pid_ != -1;
306306
}
307307

308-
template<BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void(error_code, int))
309-
WaitHandler BOOST_PROCESS_V2_DEFAULT_COMPLETION_TOKEN_TYPE(executor_type)>
310-
BOOST_PROCESS_V2_INITFN_AUTO_RESULT_TYPE(WaitHandler, void (error_code, native_exit_code_type))
311-
async_wait(WaitHandler &&handler BOOST_ASIO_DEFAULT_COMPLETION_TOKEN(executor_type))
312-
{
313-
return BOOST_PROCESS_V2_ASIO_NAMESPACE::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
314-
async_wait_op_{descriptor_, signal_set_, pid_}, handler, descriptor_);
315-
}
316-
317308
private:
318309
template<typename>
319310
friend
320311
struct basic_process_handle_fd_or_signal;
321312
pid_type pid_ = -1;
322-
BOOST_PROCESS_V2_ASIO_NAMESPACE::posix::basic_stream_descriptor<Executor> descriptor_;
323-
BOOST_PROCESS_V2_ASIO_NAMESPACE::basic_signal_set<Executor> signal_set_{descriptor_.get_executor(), SIGCHLD};
313+
net::posix::basic_stream_descriptor<Executor> descriptor_;
314+
net::basic_signal_set<Executor> signal_set_{descriptor_.get_executor(), SIGCHLD};
324315

325316
struct async_wait_op_
326317
{
327-
BOOST_PROCESS_V2_ASIO_NAMESPACE::posix::basic_descriptor<Executor> &descriptor;
328-
BOOST_PROCESS_V2_ASIO_NAMESPACE::basic_signal_set<Executor> &handle;
318+
net::posix::basic_descriptor<Executor> &descriptor;
319+
net::basic_signal_set<Executor> &handle;
329320
pid_type pid_;
330321
bool needs_post = true;
331322

332-
template<typename Self.
323+
template<typename Self>
333324
void operator()(Self && self)
334325
{
335326
self.reset_cancellation_state(asio::enable_total_cancellation());
@@ -342,7 +333,7 @@ struct basic_process_handle_fd_or_signal
342333
native_exit_code_type exit_code{};
343334
int wait_res = -1;
344335
if (pid_ <= 0) // error, complete early
345-
ec = BOOST_PROCESS_V2_ASIO_NAMESPACE::error::bad_descriptor;
336+
ec = net::error::bad_descriptor;
346337
else
347338
{
348339
wait_res = ::waitpid(pid_, &exit_code, WNOHANG);
@@ -355,7 +346,7 @@ struct basic_process_handle_fd_or_signal
355346
needs_post = false;
356347
if (descriptor.is_open())
357348
descriptor.async_wait(
358-
BOOST_PROCESS_V2_ASIO_NAMESPACE::posix::descriptor_base::wait_read,
349+
net::posix::descriptor_base::wait_read,
359350
std::move(self));
360351
else
361352
handle.async_wait(std::move(self));
@@ -377,12 +368,22 @@ struct basic_process_handle_fd_or_signal
377368
const auto exec = self.get_executor();
378369
completer cpl{ec, exit_code, std::move(self)};
379370
if (needs_post)
380-
BOOST_PROCESS_V2_ASIO_NAMESPACE::post(exec, std::move(cpl));
371+
net::post(exec, std::move(cpl));
381372
else
382-
BOOST_PROCESS_V2_ASIO_NAMESPACE::dispatch(exec, std::move(cpl));
373+
net::dispatch(exec, std::move(cpl));
383374

384375
}
385376
};
377+
public:
378+
template<BOOST_PROCESS_V2_COMPLETION_TOKEN_FOR(void(error_code, int))
379+
WaitHandler = net::default_completion_token_t<executor_type>>
380+
auto async_wait(WaitHandler &&handler = net::default_completion_token_t<executor_type>())
381+
-> decltype(net::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
382+
async_wait_op_{descriptor_, signal_set_, pid_}, handler, descriptor_))
383+
{
384+
return net::async_compose<WaitHandler, void(error_code, native_exit_code_type)>(
385+
async_wait_op_{descriptor_, signal_set_, pid_}, handler, descriptor_);
386+
}
386387
};
387388
}
388389

0 commit comments

Comments
 (0)