[gtkmm] Glib::Dispatcher::operator() reentrant?



Hi!

I just studied Glib::Dispatcher and wondered when I read in the docs:

* Only one thread may connect to the signal and receive notification, but multiple senders are allowed even without locking.

Does this mean that Glib::Dispatcher::operator() should be reentrant?
To me it doesn't look like this would be true. The function calls
DispatchNotifier::send_notification() which is defined as follows:

void DispatchNotifier::send_notification(Dispatcher* dispatcher) {
[...]
  gsize n_written = 0;

  do {
    void * const buffer = reinterpret_cast<guint8*>(&data) + n_written;
const gssize result = write(fd_sender_, buffer, sizeof(data) - n_written);

    if(result < 0) {
      if(errno == EINTR)
        continue;

      warn_failed_pipe_io("write", errno);
      return;
    }

    n_written += result;
  }
  while(n_written < sizeof(data));
}

Now what happens when a context switch occurs immediately after an
incomplete write() and a second thread calls Dispatcher::operator()?
Isn't the output into the pipe completely screwed up then?

By the way, SigC::SignalX::emit() has been removed in sigc-1.1.
Should we really have Glib::Dispatcher::emit()?

Regards,

  Martin



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]