libnghttp2_asio: Added io_service accessors

To allow the asio wrapper to work with boost.fiber it is required
to access the underlying io_service objects.
This commit is contained in:
Andreas Pohl 2015-12-08 15:47:04 +01:00
parent 4bcc14fc67
commit 924fef1f32
8 changed files with 26 additions and 0 deletions

View File

@ -92,6 +92,10 @@ boost::asio::io_service &io_service_pool::get_io_service() {
return io_service; return io_service;
} }
std::vector<std::shared_ptr<boost::asio::io_service>> &io_service_pool::get_io_services() {
return io_services_;
}
} // namespace asio_http2 } // namespace asio_http2
} // namespace nghttp2 } // namespace nghttp2

View File

@ -70,6 +70,9 @@ public:
/// Get an io_service to use. /// Get an io_service to use.
boost::asio::io_service &get_io_service(); boost::asio::io_service &get_io_service();
/// Get access to all io_service objects.
std::vector<std::shared_ptr<boost::asio::io_service>> &get_io_services();
private: private:
/// The pool of io_services. /// The pool of io_services.
std::vector<std::shared_ptr<boost::asio::io_service>> io_services_; std::vector<std::shared_ptr<boost::asio::io_service>> io_services_;

View File

@ -169,6 +169,10 @@ void server::stop() { io_service_pool_.stop(); }
void server::join() { io_service_pool_.join(); } void server::join() { io_service_pool_.join(); }
std::vector<std::shared_ptr<boost::asio::io_service>> &server::get_io_services() {
return io_service_pool_.get_io_services();
}
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2
} // namespace nghttp2 } // namespace nghttp2

View File

@ -73,6 +73,9 @@ public:
void join(); void join();
void stop(); void stop();
/// Get access to all io_service objects.
std::vector<std::shared_ptr<boost::asio::io_service>> &get_io_services();
private: private:
/// Initiate an asynchronous accept operation. /// Initiate an asynchronous accept operation.
void start_accept(tcp::acceptor &acceptor, serve_mux &mux); void start_accept(tcp::acceptor &acceptor, serve_mux &mux);

View File

@ -77,6 +77,10 @@ void http2::stop() { impl_->stop(); }
void http2::join() { return impl_->join(); } void http2::join() { return impl_->join(); }
std::vector<std::shared_ptr<boost::asio::io_service>> &http2::get_io_services() {
return impl_->get_io_services();
}
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2

View File

@ -59,6 +59,10 @@ void http2_impl::stop() { return server_->stop(); }
void http2_impl::join() { return server_->join(); } void http2_impl::join() { return server_->join(); }
std::vector<std::shared_ptr<boost::asio::io_service>> &http2_impl::get_io_services() {
return server_->get_io_services();
}
} // namespace server } // namespace server
} // namespace asio_http2 } // namespace asio_http2

View File

@ -50,6 +50,7 @@ public:
bool handle(std::string pattern, request_cb cb); bool handle(std::string pattern, request_cb cb);
void stop(); void stop();
void join(); void join();
std::vector<std::shared_ptr<boost::asio::io_service>> &get_io_services();
private: private:
std::unique_ptr<server> server_; std::unique_ptr<server> server_;

View File

@ -201,6 +201,9 @@ public:
// Join on http2 server and wait for it to fully stop // Join on http2 server and wait for it to fully stop
void join(); void join();
// Get access to the io_service objects.
std::vector<std::shared_ptr<boost::asio::io_service>> &get_io_services();
private: private:
std::unique_ptr<http2_impl> impl_; std::unique_ptr<http2_impl> impl_;
}; };