Boost logo

Boost Users :

Subject: Re: [Boost-users] Suggestion about using Signals2
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2009-03-23 05:50:58


Igor R ha scritto:
>> is there a reason to create the io_service outside the class?
>> Can I create an instance of it directly into the connection object?
>
> Yes, you can. But usually you don't want to create io_service for
> every connection or for every "active object" (you can use a single
> io_service for all these objects or use io_service-per-cpu strategy -
> see asio examples for details), that's why that you might want to
> manage io_service(s) creation outside these objects.

Ok, now I've understand!
I'm sorry but it's my first approach to asio!

> But if you use some other i/o object to communicate with socket/serial
> port, and utilize io_service just to process functors asyncronously,
> and you wish to notify connection user from io_service thread - then
> you can use the same technique there. It's just matter of your design.
> Anyway, I recommend you to look at the asio tutorial and examples, to
> find out some common usage scenarios and design proposals.

Yes, this is exactly what I have to do.
I will looking into the tutorials!!

Just one last thing..

I've tried to to something like this (where signal_OnData is a signal):

void SerialPort::reading()
{
  .... data available...
  //signal_OnData();
  _io.post( boost::bind(&SerialPort::Post_OnData, this) );
}

void SerialPort::Post_OnData()
{
  signal_OnData();
};

but the SerialPort::Post_OnData is not called, is this my design wrong?

Thanks very mutch for your support!!!
Daniele.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net