Rename execution_context members to shutdown and destroy.

The execution_context member functions shutdown_context and destroy_context
have been renamed to shutdown and destroy, respectively. Similarly,
execution_context::service::shutdown_service has been renamed to shutdown.
This commit is contained in:
Christopher Kohlhoff 2015-05-12 09:32:19 +10:00
parent d3bbf3756d
commit f1ebd9522f
65 changed files with 180 additions and 122 deletions

View File

@ -422,9 +422,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -151,9 +151,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -75,7 +75,7 @@ public:
} }
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
} }

View File

@ -59,10 +59,10 @@ public:
ASIO_DECL ~dev_poll_reactor(); ASIO_DECL ~dev_poll_reactor();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Recreate internal descriptors following a fork. // Recreate internal descriptors following a fork.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::execution_context::fork_event fork_ev); asio::execution_context::fork_event fork_ev);
// Initialise the task. // Initialise the task.

View File

@ -78,10 +78,10 @@ public:
ASIO_DECL ~epoll_reactor(); ASIO_DECL ~epoll_reactor();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Recreate internal descriptors following a fork. // Recreate internal descriptors following a fork.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::execution_context::fork_event fork_ev); asio::execution_context::fork_event fork_ev);
// Initialise the task. // Initialise the task.

View File

@ -47,11 +47,11 @@ dev_poll_reactor::dev_poll_reactor(asio::execution_context& ctx)
dev_poll_reactor::~dev_poll_reactor() dev_poll_reactor::~dev_poll_reactor()
{ {
shutdown_service(); shutdown();
::close(dev_poll_fd_); ::close(dev_poll_fd_);
} }
void dev_poll_reactor::shutdown_service() void dev_poll_reactor::shutdown()
{ {
asio::detail::mutex::scoped_lock lock(mutex_); asio::detail::mutex::scoped_lock lock(mutex_);
shutdown_ = true; shutdown_ = true;
@ -67,7 +67,7 @@ void dev_poll_reactor::shutdown_service()
scheduler_.abandon_operations(ops); scheduler_.abandon_operations(ops);
} }
void dev_poll_reactor::fork_service(asio::io_context::fork_event fork_ev) void dev_poll_reactor::notify_fork(asio::io_context::fork_event fork_ev)
{ {
if (fork_ev == asio::execution_context::fork_child) if (fork_ev == asio::execution_context::fork_child)
{ {

View File

@ -67,7 +67,7 @@ epoll_reactor::~epoll_reactor()
close(timer_fd_); close(timer_fd_);
} }
void epoll_reactor::shutdown_service() void epoll_reactor::shutdown()
{ {
mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);
shutdown_ = true; shutdown_ = true;
@ -88,7 +88,7 @@ void epoll_reactor::shutdown_service()
scheduler_.abandon_operations(ops); scheduler_.abandon_operations(ops);
} }
void epoll_reactor::fork_service( void epoll_reactor::notify_fork(
asio::execution_context::fork_event fork_ev) asio::execution_context::fork_event fork_ev)
{ {
if (fork_ev == asio::execution_context::fork_child) if (fork_ev == asio::execution_context::fork_child)

View File

@ -63,7 +63,7 @@ kqueue_reactor::~kqueue_reactor()
close(kqueue_fd_); close(kqueue_fd_);
} }
void kqueue_reactor::shutdown_service() void kqueue_reactor::shutdown()
{ {
mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);
shutdown_ = true; shutdown_ = true;
@ -84,7 +84,7 @@ void kqueue_reactor::shutdown_service()
scheduler_.abandon_operations(ops); scheduler_.abandon_operations(ops);
} }
void kqueue_reactor::fork_service( void kqueue_reactor::notify_fork(
asio::execution_context::fork_event fork_ev) asio::execution_context::fork_event fork_ev)
{ {
if (fork_ev == asio::execution_context::fork_child) if (fork_ev == asio::execution_context::fork_child)

View File

@ -36,7 +36,7 @@ reactive_descriptor_service::reactive_descriptor_service(
reactor_.init_task(); reactor_.init_task();
} }
void reactive_descriptor_service::shutdown_service() void reactive_descriptor_service::shutdown()
{ {
} }

View File

@ -35,9 +35,9 @@ reactive_serial_port_service::reactive_serial_port_service(
{ {
} }
void reactive_serial_port_service::shutdown_service() void reactive_serial_port_service::shutdown()
{ {
descriptor_service_.shutdown_service(); descriptor_service_.shutdown();
} }
asio::error_code reactive_serial_port_service::open( asio::error_code reactive_serial_port_service::open(

View File

@ -35,7 +35,7 @@ reactive_socket_service_base::reactive_socket_service_base(
reactor_.init_task(); reactor_.init_task();
} }
void reactive_socket_service_base::shutdown_service() void reactive_socket_service_base::shutdown()
{ {
} }

View File

@ -46,10 +46,10 @@ resolver_service_base::resolver_service_base(
resolver_service_base::~resolver_service_base() resolver_service_base::~resolver_service_base()
{ {
shutdown_service(); shutdown();
} }
void resolver_service_base::shutdown_service() void resolver_service_base::shutdown()
{ {
work_.reset(); work_.reset();
if (work_io_context_.get()) if (work_io_context_.get())
@ -64,7 +64,7 @@ void resolver_service_base::shutdown_service()
} }
} }
void resolver_service_base::fork_service( void resolver_service_base::notify_fork(
asio::io_context::fork_event fork_ev) asio::io_context::fork_event fork_ev)
{ {
if (work_thread_.get()) if (work_thread_.get())

View File

@ -97,7 +97,7 @@ scheduler::scheduler(
ASIO_HANDLER_TRACKING_INIT; ASIO_HANDLER_TRACKING_INIT;
} }
void scheduler::shutdown_service() void scheduler::shutdown()
{ {
mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);
shutdown_ = true; shutdown_ = true;

View File

@ -71,10 +71,10 @@ select_reactor::select_reactor(asio::execution_context& ctx)
select_reactor::~select_reactor() select_reactor::~select_reactor()
{ {
shutdown_service(); shutdown();
} }
void select_reactor::shutdown_service() void select_reactor::shutdown()
{ {
asio::detail::mutex::scoped_lock lock(mutex_); asio::detail::mutex::scoped_lock lock(mutex_);
shutdown_ = true; shutdown_ = true;
@ -103,7 +103,7 @@ void select_reactor::shutdown_service()
scheduler_.abandon_operations(ops); scheduler_.abandon_operations(ops);
} }
void select_reactor::fork_service( void select_reactor::notify_fork(
asio::execution_context::fork_event fork_ev) asio::execution_context::fork_event fork_ev)
{ {
if (fork_ev == asio::execution_context::fork_child) if (fork_ev == asio::execution_context::fork_child)

View File

@ -40,7 +40,7 @@ void service_registry::shutdown_services()
execution_context::service* service = first_service_; execution_context::service* service = first_service_;
while (service) while (service)
{ {
service->shutdown_service(); service->shutdown();
service = service->next_; service = service->next_;
} }
} }
@ -78,10 +78,10 @@ void service_registry::notify_fork(execution_context::fork_event fork_ev)
std::size_t num_services = services.size(); std::size_t num_services = services.size();
if (fork_ev == execution_context::fork_prepare) if (fork_ev == execution_context::fork_prepare)
for (std::size_t i = 0; i < num_services; ++i) for (std::size_t i = 0; i < num_services; ++i)
services[i]->fork_service(fork_ev); services[i]->notify_fork(fork_ev);
else else
for (std::size_t i = num_services; i > 0; --i) for (std::size_t i = num_services; i > 0; --i)
services[i - 1]->fork_service(fork_ev); services[i - 1]->notify_fork(fork_ev);
} }
void service_registry::init_key(execution_context::service::key& key, void service_registry::init_key(execution_context::service::key& key,

View File

@ -150,7 +150,7 @@ signal_set_service::~signal_set_service()
remove_service(this); remove_service(this);
} }
void signal_set_service::shutdown_service() void signal_set_service::shutdown()
{ {
remove_service(this); remove_service(this);
@ -169,7 +169,7 @@ void signal_set_service::shutdown_service()
io_context_.abandon_operations(ops); io_context_.abandon_operations(ops);
} }
void signal_set_service::fork_service( void signal_set_service::notify_fork(
asio::io_context::fork_event fork_ev) asio::io_context::fork_event fork_ev)
{ {
#if !defined(ASIO_WINDOWS) \ #if !defined(ASIO_WINDOWS) \

View File

@ -31,7 +31,7 @@ strand_executor_service::strand_executor_service(execution_context& ctx)
{ {
} }
void strand_executor_service::shutdown_service() void strand_executor_service::shutdown()
{ {
op_queue<scheduler_operation> ops; op_queue<scheduler_operation> ops;

View File

@ -49,7 +49,7 @@ strand_service::strand_service(asio::io_context& io_context)
{ {
} }
void strand_service::shutdown_service() void strand_service::shutdown()
{ {
op_queue<operation> ops; op_queue<operation> ops;

View File

@ -73,7 +73,7 @@ win_iocp_handle_service::win_iocp_handle_service(
{ {
} }
void win_iocp_handle_service::shutdown_service() void win_iocp_handle_service::shutdown()
{ {
// Close all implementations, causing all operations to complete. // Close all implementations, causing all operations to complete.
asio::detail::mutex::scoped_lock lock(mutex_); asio::detail::mutex::scoped_lock lock(mutex_);

View File

@ -86,7 +86,7 @@ win_iocp_io_context::win_iocp_io_context(
} }
} }
void win_iocp_io_context::shutdown_service() void win_iocp_io_context::shutdown()
{ {
::InterlockedExchange(&shutdown_, 1); ::InterlockedExchange(&shutdown_, 1);

View File

@ -34,7 +34,7 @@ win_iocp_serial_port_service::win_iocp_serial_port_service(
{ {
} }
void win_iocp_serial_port_service::shutdown_service() void win_iocp_serial_port_service::shutdown()
{ {
} }

View File

@ -37,7 +37,7 @@ win_iocp_socket_service_base::win_iocp_socket_service_base(
{ {
} }
void win_iocp_socket_service_base::shutdown_service() void win_iocp_socket_service_base::shutdown()
{ {
// Close all implementations, causing all operations to complete. // Close all implementations, causing all operations to complete.
asio::detail::mutex::scoped_lock lock(mutex_); asio::detail::mutex::scoped_lock lock(mutex_);

View File

@ -36,7 +36,7 @@ win_object_handle_service::win_object_handle_service(
{ {
} }
void win_object_handle_service::shutdown_service() void win_object_handle_service::shutdown()
{ {
mutex::scoped_lock lock(mutex_); mutex::scoped_lock lock(mutex_);

View File

@ -38,7 +38,7 @@ winrt_ssocket_service_base::winrt_ssocket_service_base(
{ {
} }
void winrt_ssocket_service_base::shutdown_service() void winrt_ssocket_service_base::shutdown()
{ {
// Close all implementations, causing all operations to complete. // Close all implementations, causing all operations to complete.
asio::detail::mutex::scoped_lock lock(mutex_); asio::detail::mutex::scoped_lock lock(mutex_);

View File

@ -44,10 +44,10 @@ winrt_timer_scheduler::winrt_timer_scheduler(
winrt_timer_scheduler::~winrt_timer_scheduler() winrt_timer_scheduler::~winrt_timer_scheduler()
{ {
shutdown_service(); shutdown();
} }
void winrt_timer_scheduler::shutdown_service() void winrt_timer_scheduler::shutdown()
{ {
asio::detail::mutex::scoped_lock lock(mutex_); asio::detail::mutex::scoped_lock lock(mutex_);
shutdown_ = true; shutdown_ = true;
@ -67,7 +67,7 @@ void winrt_timer_scheduler::shutdown_service()
io_context_.abandon_operations(ops); io_context_.abandon_operations(ops);
} }
void winrt_timer_scheduler::fork_service(asio::io_context::fork_event) void winrt_timer_scheduler::notify_fork(asio::io_context::fork_event)
{ {
} }

View File

@ -82,10 +82,10 @@ public:
ASIO_DECL ~kqueue_reactor(); ASIO_DECL ~kqueue_reactor();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Recreate internal descriptors following a fork. // Recreate internal descriptors following a fork.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::execution_context::fork_event fork_ev); asio::execution_context::fork_event fork_ev);
// Initialise the task. // Initialise the task.

View File

@ -43,7 +43,7 @@ public:
} }
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
} }

View File

@ -55,7 +55,7 @@ public:
} }
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
} }

View File

@ -78,7 +78,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new descriptor implementation. // Construct a new descriptor implementation.
ASIO_DECL void construct(implementation_type& impl); ASIO_DECL void construct(implementation_type& impl);

View File

@ -47,7 +47,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new serial port implementation. // Construct a new serial port implementation.
void construct(implementation_type& impl) void construct(implementation_type& impl)

View File

@ -66,7 +66,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new socket implementation. // Construct a new socket implementation.
ASIO_DECL void construct(base_implementation_type& impl); ASIO_DECL void construct(base_implementation_type& impl);

View File

@ -45,10 +45,10 @@ public:
ASIO_DECL ~resolver_service_base(); ASIO_DECL ~resolver_service_base();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Perform any fork-related housekeeping. // Perform any fork-related housekeeping.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::io_context::fork_event fork_ev); asio::io_context::fork_event fork_ev);
// Construct a new resolver implementation. // Construct a new resolver implementation.

View File

@ -47,7 +47,7 @@ public:
std::size_t concurrency_hint = 0); std::size_t concurrency_hint = 0);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Initialise the task, if required. // Initialise the task, if required.
ASIO_DECL void init_task(); ASIO_DECL void init_task();
@ -113,8 +113,8 @@ public:
// operation for immediate invocation. // operation for immediate invocation.
ASIO_DECL void do_dispatch(operation* op); ASIO_DECL void do_dispatch(operation* op);
// Process unfinished operations as part of a shutdown_service operation. // Process unfinished operations as part of a shutdownoperation. Assumes that
// Assumes that work_started() was previously called for the operations. // work_started() was previously called for the operations.
ASIO_DECL void abandon_operations(op_queue<operation>& ops); ASIO_DECL void abandon_operations(op_queue<operation>& ops);
private: private:

View File

@ -70,10 +70,10 @@ public:
ASIO_DECL ~select_reactor(); ASIO_DECL ~select_reactor();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Recreate internal descriptors following a fork. // Recreate internal descriptors following a fork.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::execution_context::fork_event fork_ev); asio::execution_context::fork_event fork_ev);
// Initialise the task, but only if the reactor is not in its own thread. // Initialise the task, but only if the reactor is not in its own thread.

View File

@ -114,10 +114,10 @@ public:
ASIO_DECL ~signal_set_service(); ASIO_DECL ~signal_set_service();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Perform fork-related housekeeping. // Perform fork-related housekeeping.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::io_context::fork_event fork_ev); asio::io_context::fork_event fork_ev);
// Construct a new signal_set implementation. // Construct a new signal_set implementation.

View File

@ -76,7 +76,7 @@ public:
ASIO_DECL explicit strand_executor_service(execution_context& context); ASIO_DECL explicit strand_executor_service(execution_context& context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Create a new strand_executor implementation. // Create a new strand_executor implementation.
ASIO_DECL implementation_type create_implementation(); ASIO_DECL implementation_type create_implementation();

View File

@ -78,7 +78,7 @@ public:
ASIO_DECL explicit strand_service(asio::io_context& io_context); ASIO_DECL explicit strand_service(asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new strand implementation. // Construct a new strand implementation.
ASIO_DECL void construct(implementation_type& impl); ASIO_DECL void construct(implementation_type& impl);

View File

@ -77,7 +77,7 @@ public:
ASIO_DECL win_iocp_handle_service(asio::io_context& io_context); ASIO_DECL win_iocp_handle_service(asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new handle implementation. // Construct a new handle implementation.
ASIO_DECL void construct(implementation_type& impl); ASIO_DECL void construct(implementation_type& impl);

View File

@ -51,7 +51,7 @@ public:
size_t concurrency_hint = 0); size_t concurrency_hint = 0);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Initialise the task. Nothing to do here. // Initialise the task. Nothing to do here.
void init_task() void init_task()
@ -148,8 +148,8 @@ public:
post_immediate_completion(op, false); post_immediate_completion(op, false);
} }
// Process unfinished operations as part of a shutdown_service operation. // Process unfinished operations as part of a shutdown operation. Assumes
// Assumes that work_started() was previously called for the operations. // that work_started() was previously called for the operations.
ASIO_DECL void abandon_operations(op_queue<operation>& ops); ASIO_DECL void abandon_operations(op_queue<operation>& ops);
// Called after starting an overlapped I/O operation that did not complete // Called after starting an overlapped I/O operation that did not complete

View File

@ -45,7 +45,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new serial port implementation. // Construct a new serial port implementation.
void construct(implementation_type& impl) void construct(implementation_type& impl)

View File

@ -89,7 +89,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new socket implementation. // Construct a new socket implementation.
ASIO_DECL void construct(base_implementation_type& impl); ASIO_DECL void construct(base_implementation_type& impl);

View File

@ -82,7 +82,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new handle implementation. // Construct a new handle implementation.
ASIO_DECL void construct(implementation_type& impl); ASIO_DECL void construct(implementation_type& impl);

View File

@ -48,7 +48,7 @@ public:
} }
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
if (--outstanding_ops_ > 0) if (--outstanding_ops_ > 0)
{ {

View File

@ -64,12 +64,12 @@ public:
} }
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
} }
// Perform any fork-related housekeeping. // Perform any fork-related housekeeping.
void fork_service(asio::io_context::fork_event) void notify_fork(asio::io_context::fork_event)
{ {
} }

View File

@ -65,7 +65,7 @@ public:
asio::io_context& io_context); asio::io_context& io_context);
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Construct a new socket implementation. // Construct a new socket implementation.
ASIO_DECL void construct(base_implementation_type&); ASIO_DECL void construct(base_implementation_type&);

View File

@ -50,10 +50,10 @@ public:
ASIO_DECL ~winrt_timer_scheduler(); ASIO_DECL ~winrt_timer_scheduler();
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
ASIO_DECL void shutdown_service(); ASIO_DECL void shutdown();
// Recreate internal descriptors following a fork. // Recreate internal descriptors following a fork.
ASIO_DECL void fork_service( ASIO_DECL void notify_fork(
asio::io_context::fork_event fork_ev); asio::io_context::fork_event fork_ev);
// Initialise the task. No effect as this class uses its own thread. // Initialise the task. No effect as this class uses its own thread.

View File

@ -83,8 +83,8 @@ namespace detail { class service_registry; }
* type. * type.
* *
* On destruction, a class that is derived from execution_context must perform * On destruction, a class that is derived from execution_context must perform
* <tt>execution_context::shutdown_context()</tt> followed by * <tt>execution_context::shutdown()</tt> followed by
* <tt>execution_context::destroy_context()</tt>. * <tt>execution_context::destroy()</tt>.
* *
* This destruction sequence permits programs to simplify their resource * This destruction sequence permits programs to simplify their resource
* management by using @c shared_ptr<>. Where an object's lifetime is tied to * management by using @c shared_ptr<>. Where an object's lifetime is tied to
@ -98,9 +98,9 @@ namespace detail { class service_registry; }
* *
* @li To shut down the whole program, the io_context function stop() is called * @li To shut down the whole program, the io_context function stop() is called
* to terminate any run() calls as soon as possible. The io_context destructor * to terminate any run() calls as soon as possible. The io_context destructor
* calls @c shutdown_context() and @c destroy_context() to destroy all pending * calls @c shutdown() and @c destroy() to destroy all pending handlers,
* handlers, causing all @c shared_ptr references to all connection objects to * causing all @c shared_ptr references to all connection objects to be
* be destroyed. * destroyed.
*/ */
class execution_context class execution_context
: private noncopyable : private noncopyable
@ -122,9 +122,9 @@ protected:
* *
* @li For each service object @c svc in the execution_context set, in * @li For each service object @c svc in the execution_context set, in
* reverse order of the beginning of service object lifetime, performs @c * reverse order of the beginning of service object lifetime, performs @c
* svc->shutdown_service(). * svc->shutdown().
*/ */
ASIO_DECL void shutdown_context(); ASIO_DECL void shutdown();
/// Destroys all services in the context. /// Destroys all services in the context.
/** /**
@ -134,7 +134,7 @@ protected:
* reverse order * of the beginning of service object lifetime, performs * reverse order * of the beginning of service object lifetime, performs
* <tt>delete static_cast<execution_context::service*>(svc)</tt>. * <tt>delete static_cast<execution_context::service*>(svc)</tt>.
*/ */
ASIO_DECL void destroy_context(); ASIO_DECL void destroy();
public: public:
/// Fork-related event notifications. /// Fork-related event notifications.
@ -185,7 +185,7 @@ public:
* } @endcode * } @endcode
* *
* @note For each service object @c svc in the execution_context set, * @note For each service object @c svc in the execution_context set,
* performs <tt>svc->fork_service();</tt>. When processing the fork_prepare * performs <tt>svc->notify_fork();</tt>. When processing the fork_prepare
* event, services are visited in reverse order of the beginning of service * event, services are visited in reverse order of the beginning of service
* object lifetime. Otherwise, services are visited in order of the beginning * object lifetime. Otherwise, services are visited in order of the beginning
* of service object lifetime. * of service object lifetime.
@ -330,7 +330,7 @@ protected:
private: private:
/// Destroy all user-defined handler objects owned by the service. /// Destroy all user-defined handler objects owned by the service.
virtual void shutdown_service() = 0; virtual void shutdown() = 0;
/// Handle notification of a fork-related event to perform any necessary /// Handle notification of a fork-related event to perform any necessary
/// housekeeping. /// housekeeping.
@ -338,7 +338,7 @@ private:
* This function is not a pure virtual so that services only have to * This function is not a pure virtual so that services only have to
* implement it if necessary. The default implementation does nothing. * implement it if necessary. The default implementation does nothing.
*/ */
ASIO_DECL virtual void fork_service( ASIO_DECL virtual void notify_fork(
execution_context::fork_event event); execution_context::fork_event event);
friend class asio::detail::service_registry; friend class asio::detail::service_registry;

View File

@ -30,17 +30,17 @@ execution_context::execution_context()
execution_context::~execution_context() execution_context::~execution_context()
{ {
shutdown_context(); shutdown();
destroy_context(); destroy();
delete service_registry_; delete service_registry_;
} }
void execution_context::shutdown_context() void execution_context::shutdown()
{ {
service_registry_->shutdown_services(); service_registry_->shutdown_services();
} }
void execution_context::destroy_context() void execution_context::destroy()
{ {
service_registry_->destroy_services(); service_registry_->destroy_services();
} }
@ -61,7 +61,7 @@ execution_context::service::~service()
{ {
} }
void execution_context::service::fork_service(execution_context::fork_event) void execution_context::service::notify_fork(execution_context::fork_event)
{ {
} }

View File

@ -130,6 +130,34 @@ io_context::service::~service()
{ {
} }
void io_context::service::shutdown()
{
#if !defined(ASIO_NO_DEPRECATED)
shutdown_service();
#endif // !defined(ASIO_NO_DEPRECATED)
}
#if !defined(ASIO_NO_DEPRECATED)
void io_context::service::shutdown_service()
{
}
#endif // !defined(ASIO_NO_DEPRECATED)
void io_context::service::notify_fork(io_context::fork_event ev)
{
#if !defined(ASIO_NO_DEPRECATED)
fork_service(ev);
#else // !defined(ASIO_NO_DEPRECATED)
(void)ev;
#endif // !defined(ASIO_NO_DEPRECATED)
}
#if !defined(ASIO_NO_DEPRECATED)
void io_context::service::fork_service(io_context::fork_event)
{
}
#endif // !defined(ASIO_NO_DEPRECATED)
} // namespace asio } // namespace asio
#include "asio/detail/pop_options.hpp" #include "asio/detail/pop_options.hpp"

View File

@ -179,7 +179,7 @@ public:
* *
* @li For each service object @c svc in the io_context set, in reverse order * @li For each service object @c svc in the io_context set, in reverse order
* of the beginning of service object lifetime, performs * of the beginning of service object lifetime, performs
* @c svc->shutdown_service(). * @c svc->shutdown().
* *
* @li Uninvoked handler objects that were scheduled for deferred invocation * @li Uninvoked handler objects that were scheduled for deferred invocation
* on the io_context, or any associated strand, are destroyed. * on the io_context, or any associated strand, are destroyed.
@ -684,6 +684,36 @@ public:
asio::io_context& get_io_service(); asio::io_context& get_io_service();
#endif // !defined(ASIO_NO_DEPRECATED) #endif // !defined(ASIO_NO_DEPRECATED)
private:
/// Destroy all user-defined handler objects owned by the service.
ASIO_DECL virtual void shutdown();
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use shutdown().) Destroy all user-defined handler objects
/// owned by the service.
ASIO_DECL virtual void shutdown_service();
#endif // !defined(ASIO_NO_DEPRECATED)
/// Handle notification of a fork-related event to perform any necessary
/// housekeeping.
/**
* This function is not a pure virtual so that services only have to
* implement it if necessary. The default implementation does nothing.
*/
ASIO_DECL virtual void notify_fork(
execution_context::fork_event event);
#if !defined(ASIO_NO_DEPRECATED)
/// (Deprecated: Use notify_fork().) Handle notification of a fork-related
/// event to perform any necessary housekeeping.
/**
* This function is not a pure virtual so that services only have to
* implement it if necessary. The default implementation does nothing.
*/
ASIO_DECL virtual void fork_service(
execution_context::fork_event event);
#endif // !defined(ASIO_NO_DEPRECATED)
protected: protected:
/// Constructor. /// Constructor.
/** /**

View File

@ -155,15 +155,15 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// Perform any fork-related housekeeping. // Perform any fork-related housekeeping.
void fork_service(asio::io_context::fork_event event) void notify_fork(asio::io_context::fork_event event)
{ {
service_impl_.fork_service(event); service_impl_.notify_fork(event);
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -248,9 +248,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -422,9 +422,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -372,9 +372,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -219,9 +219,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -111,15 +111,15 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// Perform any fork-related housekeeping. // Perform any fork-related housekeeping.
void fork_service(asio::io_context::fork_event event) void notify_fork(asio::io_context::fork_event event)
{ {
service_impl_.fork_service(event); service_impl_.notify_fork(event);
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -326,9 +326,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -368,9 +368,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -189,9 +189,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -156,9 +156,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -185,9 +185,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -183,9 +183,9 @@ public:
private: private:
// Destroy all user-defined handler objects owned by the service. // Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
service_impl_.shutdown_service(); service_impl_.shutdown();
} }
// The platform-specific implementation. // The platform-specific implementation.

View File

@ -52,7 +52,7 @@ public:
} }
/// Destroy all user-defined handler objects owned by the service. /// Destroy all user-defined handler objects owned by the service.
void shutdown_service() void shutdown()
{ {
} }

View File

@ -43,7 +43,7 @@ private:
} }
private: private:
virtual void shutdown_service() virtual void shutdown()
{ {
for (auto& t : threads_) for (auto& t : threads_)
t.join(); t.join();

View File

@ -38,7 +38,7 @@ private:
} }
private: private:
virtual void shutdown_service() virtual void shutdown()
{ {
for (auto& t : threads_) for (auto& t : threads_)
t.join(); t.join();