Boost logo

Boost Users :

Subject: Re: [Boost-users] Suggestion about using Signals2
From: Daniele Barzotti (daniele.barzotti_at_[hidden])
Date: 2009-03-20 07:13:34


Daniele Barzotti wrote:
>
> I have a thread that reads from the RS232:
>
> void SerialPort::reading()
> {
> ... read...
> if (data_available) signal_OnData;
> }
>
> the signal_OnData is:
>
> typedef boost::signals2::signal<void ()> _signal_void;
> _signal_void signal_OnData;
>
> And I connect it to a method MyUserClass::OnDataReceived()
>
> Into this method (MyUserClass::OnDataReceived) I need to re-send some
> data to RS232, but the SerialPort::reading thread is locked because it's
> waiting the OnDataReceived ends..
>
> In fact, when the methods OnDataReceived ends, I receive data again.

I have solve this issue creating a new thread to manage data:

MyUserClass::OnDataReceived()
{
  // Create New Thread
  try {
    _read_thread_ptr.reset( new
boost::thread(boost::bind(&MyUserClass::ManageData, this)) );
  } catch (boost::thread_resource_error e) {
    // Failed to create the new thread
    return;
  }
}

But another problem is raised: when I receive 2 command one after other
quickly, I miss the second, so...

Is there a method to launch a signal directly into another thread?
Something like:

boost::thread(boost::bind(signal_OnData, ptrToObj))

thanks in advance!
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