Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r55044 - in branches/release: . libs/asio/doc/requirements
From: chris_at_[hidden]
Date: 2009-07-20 09:16:23


Author: chris_kohlhoff
Date: 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
New Revision: 55044
URL: http://svn.boost.org/trac/boost/changeset/55044

Log:
Merged examples for handler type requirements from trunk.

Properties modified:
   branches/release/ (props changed)
Text files modified:
   branches/release/libs/asio/doc/requirements/AcceptHandler.qbk | 35 +++++++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/requirements/CompletionHandler.qbk | 31 +++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/requirements/ConnectHandler.qbk | 35 +++++++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/requirements/ReadHandler.qbk | 39 +++++++++++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/requirements/ResolveHandler.qbk | 39 +++++++++++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/requirements/WaitHandler.qbk | 35 +++++++++++++++++++++++++++++++++++
   branches/release/libs/asio/doc/requirements/WriteHandler.qbk | 39 +++++++++++++++++++++++++++++++++++++++
   7 files changed, 253 insertions(+), 0 deletions(-)

Modified: branches/release/libs/asio/doc/requirements/AcceptHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/AcceptHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/AcceptHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -12,4 +12,39 @@
 class should work correctly in the expression `h(ec)`, where `ec` is an lvalue
 of type `const error_code`.
 
+[heading Examples]
+
+A free function as an accept handler:
+
+ void accept_handler(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+
+An accept handler function object:
+
+ struct accept_handler
+ {
+ ...
+ void operator()(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to an accept handler using `bind()`:
+
+ void my_class::accept_handler(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+ ...
+ acceptor.async_accept(...,
+ boost::bind(&my_class::accept_handler,
+ this, boost::asio::placeholders::error));
+
 [endsect]

Modified: branches/release/libs/asio/doc/requirements/CompletionHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/CompletionHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/CompletionHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -11,4 +11,35 @@
 boost_asio.reference.Handler handler]. A value `h` of a completion handler
 class should work correctly in the expression `h()`.
 
+[heading Examples]
+
+A free function as a completion handler:
+
+ void completion_handler()
+ {
+ ...
+ }
+
+A completion handler function object:
+
+ struct completion_handler
+ {
+ ...
+ void operator()()
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to a completion handler using
+`bind()`:
+
+ void my_class::completion_handler()
+ {
+ ...
+ }
+ ...
+ my_io_service.post(boost::bind(&my_class::completion_handler, this));
+
 [endsect]

Modified: branches/release/libs/asio/doc/requirements/ConnectHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/ConnectHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/ConnectHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -12,4 +12,39 @@
 class should work correctly in the expression `h(ec)`, where `ec` is an lvalue
 of type `const error_code`.
 
+[heading Examples]
+
+A free function as a connect handler:
+
+ void connect_handler(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+
+A connect handler function object:
+
+ struct connect_handler
+ {
+ ...
+ void operator()(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to a connect handler using `bind()`:
+
+ void my_class::connect_handler(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+ ...
+ socket.async_connect(...,
+ boost::bind(&my_class::connect_handler,
+ this, boost::asio::placeholders::error));
+
 [endsect]

Modified: branches/release/libs/asio/doc/requirements/ReadHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/ReadHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/ReadHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -12,4 +12,43 @@
 should work correctly in the expression `h(ec, s)`, where `ec` is an lvalue of
 type `const error_code` and `s` is an lvalue of type `const size_t`.
 
+[heading Examples]
+
+A free function as a read handler:
+
+ void read_handler(
+ const boost::system::error_code& ec,
+ std::size_t bytes_transferred)
+ {
+ ...
+ }
+
+A read handler function object:
+
+ struct read_handler
+ {
+ ...
+ void operator()(
+ const boost::system::error_code& ec,
+ std::size_t bytes_transferred)
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to a read handler using `bind()`:
+
+ void my_class::read_handler(
+ const boost::system::error_code& ec,
+ std::size_t bytes_transferred)
+ {
+ ...
+ }
+ ...
+ socket.async_read(...,
+ boost::bind(&my_class::read_handler,
+ this, boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+
 [endsect]

Modified: branches/release/libs/asio/doc/requirements/ResolveHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/ResolveHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/ResolveHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -15,4 +15,43 @@
 template parameter of the [link boost_asio.reference.ip__resolver_service
 `resolver_service`] which is used to initiate the asynchronous operation.
 
+[heading Examples]
+
+A free function as a resolve handler:
+
+ void resolve_handler(
+ const boost::system::error_code& ec,
+ boost::asio::ip::tcp::resolver::iterator iterator)
+ {
+ ...
+ }
+
+A resolve handler function object:
+
+ struct resolve_handler
+ {
+ ...
+ void operator()(
+ const boost::system::error_code& ec,
+ boost::asio::ip::tcp::resolver::iterator iterator)
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to a resolve handler using `bind()`:
+
+ void my_class::resolve_handler(
+ const boost::system::error_code& ec,
+ boost::asio::ip::tcp::resolver::iterator iterator)
+ {
+ ...
+ }
+ ...
+ resolver.async_resolve(...,
+ boost::bind(&my_class::resolve_handler,
+ this, boost::asio::placeholders::error,
+ boost::asio::placeholders::iterator));
+
 [endsect]

Modified: branches/release/libs/asio/doc/requirements/WaitHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/WaitHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/WaitHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -12,4 +12,39 @@
 should work correctly in the expression `h(ec)`, where `ec` is an lvalue of
 type `const error_code`.
 
+[heading Examples]
+
+A free function as a wait handler:
+
+ void wait_handler(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+
+A wait handler function object:
+
+ struct wait_handler
+ {
+ ...
+ void operator()(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to a wait handler using `bind()`:
+
+ void my_class::wait_handler(
+ const boost::system::error_code& ec)
+ {
+ ...
+ }
+ ...
+ socket.async_wait(...,
+ boost::bind(&my_class::wait_handler,
+ this, boost::asio::placeholders::error));
+
 [endsect]

Modified: branches/release/libs/asio/doc/requirements/WriteHandler.qbk
==============================================================================
--- branches/release/libs/asio/doc/requirements/WriteHandler.qbk (original)
+++ branches/release/libs/asio/doc/requirements/WriteHandler.qbk 2009-07-20 09:16:23 EDT (Mon, 20 Jul 2009)
@@ -12,4 +12,43 @@
 should work correctly in the expression `h(ec, s)`, where `ec` is an lvalue of
 type `const error_code` and `s` is an lvalue of type `const size_t`.
 
+[heading Examples]
+
+A free function as a write handler:
+
+ void write_handler(
+ const boost::system::error_code& ec,
+ std::size_t bytes_transferred)
+ {
+ ...
+ }
+
+A write handler function object:
+
+ struct write_handler
+ {
+ ...
+ void operator()(
+ const boost::system::error_code& ec,
+ std::size_t bytes_transferred)
+ {
+ ...
+ }
+ ...
+ };
+
+A non-static class member function adapted to a write handler using `bind()`:
+
+ void my_class::write_handler(
+ const boost::system::error_code& ec,
+ std::size_t bytes_transferred)
+ {
+ ...
+ }
+ ...
+ socket.async_write(...,
+ boost::bind(&my_class::write_handler,
+ this, boost::asio::placeholders::error,
+ boost::asio::placeholders::bytes_transferred));
+
 [endsect]


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk