|
Boost : |
From: Christopher Kohlhoff (chris_at_[hidden])
Date: 2005-08-19 06:55:28
Hi Minh,
--- Mr Minh <m_phanivong_at_[hidden]> wrote:
> how would the iostreams source/sink fit into your design
I'm not particular familiar with the Boost.Iostreams library, but it
seems that template adapters could be used to turn the Sync_Recv_Stream
concept into a Source, and a Sync_Send_Stream into a Sink. There does
not seem to be an equivalent for the async concepts though.
> and would you consider using signal/slots to handle the events.
The current design makes the callback function object (aka Handler)
type a template parameter to give maximum scope for optimisation.
However there is no reason that I can see why you can't pass a signal
to be the handler. For example:
//------------------------------
#include <boost/signal.hpp>
#include <boost/bind.hpp>
#include <asio.hpp>
#include <iostream>
void func(int value)
{
std::cout << value << std::endl;
}
int main()
{
boost::signal<void()> sig;
sig.connect(boost::bind(func, 1));
sig.connect(boost::bind(func, 2));
asio::demuxer d;
d.post(boost::bind(boost::ref(sig)));
d.run();
return 0;
}
//------------------------------
Cheers,
Chris
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk