1 CrossThreadChannel::CrossThreadChannel (bool non_blocking)
8 error << "cannot create x-thread pipe for read (%2)" << ::strerror (errno) << endmsg;
13 if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
14 error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
18 if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
19 error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
24 receive_channel = g_io_channel_unix_new (fds[0]);
27 CrossThreadChannel::~CrossThreadChannel ()
29 if (receive_channel) {
30 g_io_channel_unref (receive_channel);
45 CrossThreadChannel::wakeup ()
48 (void) ::write (fds[1], &c, 1);
52 CrossThreadChannel::drain ()
55 while (::read (fds[0], buf, sizeof (buf)) > 0) {};
59 CrossThreadChannel::deliver (char msg)
61 return ::write (fds[1], &msg, 1);
65 CrossThreadChannel::receive (char& msg)
67 return ::read (fds[0], &msg, 1);