X-Git-Url: https://git.proxmox.com/?a=blobdiff_plain;f=ceph%2Fsrc%2Fboost%2Flibs%2Fasio%2Fexample%2Fcpp03%2Fservices%2Flogger_service.hpp;h=071d6bfc5e453d6cdcaa19eae4130159ab4205d3;hb=b32b81446b3b05102be0267e79203f59329c1d97;hp=968df9d135606f3007171351f511cdd4f0ecf619;hpb=215dd7151453fae88e6f968c975b6ce309d42dcf;p=ceph.git diff --git a/ceph/src/boost/libs/asio/example/cpp03/services/logger_service.hpp b/ceph/src/boost/libs/asio/example/cpp03/services/logger_service.hpp index 968df9d13..071d6bfc5 100644 --- a/ceph/src/boost/libs/asio/example/cpp03/services/logger_service.hpp +++ b/ceph/src/boost/libs/asio/example/cpp03/services/logger_service.hpp @@ -2,7 +2,7 @@ // logger_service.hpp // ~~~~~~~~~~~~~~~~~~ // -// Copyright (c) 2003-2016 Christopher M. Kohlhoff (chris at kohlhoff dot com) +// Copyright (c) 2003-2017 Christopher M. Kohlhoff (chris at kohlhoff dot com) // // Distributed under the Boost Software License, Version 1.0. (See accompanying // file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt) @@ -25,11 +25,11 @@ namespace services { /// Service implementation for the logger. class logger_service - : public boost::asio::io_service::service + : public boost::asio::io_context::service { public: /// The unique service identifier. - static boost::asio::io_service::id id; + static boost::asio::io_context::id id; /// The backend implementation of a logger. struct logger_impl @@ -41,21 +41,21 @@ public: /// The type for an implementation of the logger. typedef logger_impl* impl_type; - /// Constructor creates a thread to run a private io_service. - logger_service(boost::asio::io_service& io_service) - : boost::asio::io_service::service(io_service), - work_io_service_(), - work_(new boost::asio::io_service::work(work_io_service_)), + /// Constructor creates a thread to run a private io_context. + logger_service(boost::asio::io_context& io_context) + : boost::asio::io_context::service(io_context), + work_io_context_(), + work_(boost::asio::make_work_guard(work_io_context_)), work_thread_(new boost::thread( - boost::bind(&boost::asio::io_service::run, &work_io_service_))) + boost::bind(&boost::asio::io_context::run, &work_io_context_))) { } - /// Destructor shuts down the private io_service. + /// Destructor shuts down the private io_context. ~logger_service() { - /// Indicate that we have finished with the private io_service. Its - /// io_service::run() function will exit once all other work has completed. + /// Indicate that we have finished with the private io_context. Its + /// io_context::run() function will exit once all other work has completed. work_.reset(); if (work_thread_) work_thread_->join(); @@ -92,7 +92,7 @@ public: void use_file(impl_type& /*impl*/, const std::string& file) { // Pass the work of opening the file to the background thread. - work_io_service_.post(boost::bind( + boost::asio::post(work_io_context_, boost::bind( &logger_service::use_file_impl, this, file)); } @@ -103,14 +103,14 @@ public: std::ostringstream os; os << impl->identifier << ": " << message; - // Pass the work of opening the file to the background thread. - work_io_service_.post(boost::bind( + // Pass the work of writing to the file to the background thread. + boost::asio::post(work_io_context_, boost::bind( &logger_service::log_impl, this, os.str())); } private: /// Helper function used to open the output file from within the private - /// io_service's thread. + /// io_context's thread. void use_file_impl(const std::string& file) { ofstream_.close(); @@ -118,22 +118,23 @@ private: ofstream_.open(file.c_str()); } - /// Helper function used to log a message from within the private io_service's + /// Helper function used to log a message from within the private io_context's /// thread. void log_impl(const std::string& text) { ofstream_ << text << std::endl; } - /// Private io_service used for performing logging operations. - boost::asio::io_service work_io_service_; + /// Private io_context used for performing logging operations. + boost::asio::io_context work_io_context_; - /// Work for the private io_service to perform. If we do not give the - /// io_service some work to do then the io_service::run() function will exit + /// Work for the private io_context to perform. If we do not give the + /// io_context some work to do then the io_context::run() function will exit /// immediately. - boost::scoped_ptr work_; + boost::asio::executor_work_guard< + boost::asio::io_context::executor_type> work_; - /// Thread used for running the work io_service's run loop. + /// Thread used for running the work io_context's run loop. boost::scoped_ptr work_thread_; /// The file to which log messages will be written.