Hi all,
Although the pattern of "passing the
buck" has been mentioned in several places in the context of
Boost.Asio, I didn't find any self-contained example that demonstrates
it in a reusable manner.
So, after going through all the information I could find, I tried to
create such an example that demonstrates it using C++03.I would like to ask for feedback related to the attached
sample code (its "Test Infrastructure" and "Test Code" sections) and
double check that it does indeed depict what "passing the buck" means.
For future reference I'm listing here the all the
sources of information I could find related to the pattern of "passing
the buck". it also turned
out that a helper utility is needed in order to wrap boost::bind
created handlers and have the wrapper integrate with the Asio
customization points.
- N3388 paper: Using Asio with C++11
http://www.open-std.org/jtc1/sc22/wg21/docs/papers/2012/n3388.pdf
The "Managing Complexity" chapter references the "pass the buck"
strategy with slides 113 and 114 showing invocation and allocation
hooks that call the hooks of a nested handler.
- The implementation of higher level functions from Boost.Asio like async_read or async_write.
The problem with them being an example of the pattern is that
they are using custom classes for the intermediary operation handlers
instead of relying on boost::bind to build them on the fly.
For example its handler wrapper: context_alloc_handler and its usage in the echo server implementation.