Example of building async active object

Here's a more complex example of building communicating objects on the top of boost::asio (Boost C++ Libraries). https://sourceforge.net/projects/asio-samples/ (the most complete projects are "nmea_client" and "echo_server"). The main concept of the described method is the creation of active objects tied to boost::asio::io_service (where theirs activity is done by means of the working threads tied to io_service::run method) with asio-like communication interface:

template <typename Handler>
void async_do_something(operation_parameters, Handler handler) {...}

or even (see ma::nmea::cyclic_read_session::async_read_some)

template <typename Handler, typename Data>
void async_do_something(Data data, Handler handler) {...}

The central point of the suggested method is ma::handler_storage class which is used for handler's "parking" until the active method execution flow completes. Also ma::handler_storage helps to decouple header files from cpp-files which in theory must help with compilation time duration.

P.S.
There isn't any ready file packets at asio-samples yet - use SVN repository to download project's trunk or watch the code from browser (Code|SVN Browse). For testing purposes I use Virtual Serial Port Emulator (test configuration at data/nmea_client/test/com_emul_config.vspe) with (not valid but near) nmea log located at data/nmea_client/test/test_data.nmea.

Edit | Attach | Print version | History: r21 | r18 < r17 < r16 < r15 | Backlinks | Raw View | Raw edit | More topic actions...
Topic revision: r16 - 08 Nov 2010 - 15:31:54 - MaratAbrarov?
 
This site is powered by the TWiki collaboration platformCopyright © by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback