Boost logo

Boost Users :

Subject: Re: [Boost-users] Suggestion about using Signals2
From: Igor R (boost.lists_at_[hidden])
Date: 2009-03-21 14:52:20

> You mean using asio::io_service::post instead of signals or using asio::serial_port instead of my serial classes?

No I just mean using asio::io_service as a functor queue processor,
but if you use asio you definitely can benefit from its serial_port
class as well.

> If you have a minimal code snippet I will grateful!

If you want to see a working code with asio, you can refer to one the
asio examples, but in general I mean the following scheme

// encapsulates yours or asio i/o object, like socket, serial_port etc.
class connection : public boost::enable_shared_from_this<connection>
  connection(boost::asio::io_service &io) : io_(io)
  void send(data_type data)
    // since send() might be called from a client thread, do not
process the data here,
    // just post it to the io_ thread(s), where the data will be
delivered to the socket/port, shared_from_this(), data);
  // this method is always called within io_ thread(s)
  void data_received()
    //issue the signal
  void do_send(data_type data)
    // send the data

// listens to the connection;
class data_receiver
  void data_received(data_type data)

Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at