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 "nmea_client", "echo_server", "echo_server2", "echo_server3" projects are ready).

The main concept of the described method is the creation of active (!) objects with asio-like communication interface:

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

Because of templates' complexity (and the impossibility to separate interface - *.h, from implementation - *.cpp) the "echo_server3" project was switched to another approach:

void async_do_something(operation_parameters, 
    const boost::shared_ptr<allocator>&,
    const boost::weak_ptr<handler>&) {...}

where "allocator" (is used for asio custom memory allocation mechanism and also it can hold operation-lifetime-bounded "operation_parameters") and "handler" are predefined interfaces (abstract classes).

Topic revision: r11 - 02 Jul 2010 - 20:48:28 - 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