summaryrefslogtreecommitdiff
path: root/libs/pbd/crossthread.win.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2015-03-01 19:59:50 +0100
committerRobin Gareus <robin@gareus.org>2015-03-01 20:49:55 +0100
commitd7727a77e0b19ecb2d1957d1e13d554dbed58243 (patch)
treeb4bf35e94e2670c8e62a290cb5e364fa0b5b7a05 /libs/pbd/crossthread.win.cc
parent60388f975c7731fbfa69327c2374cf83f39d85ce (diff)
Xthread: blocking read + non-blocking write mode.
Needed for switching the butler to use Crossthreads.
Diffstat (limited to 'libs/pbd/crossthread.win.cc')
-rw-r--r--libs/pbd/crossthread.win.cc29
1 files changed, 28 insertions, 1 deletions
diff --git a/libs/pbd/crossthread.win.cc b/libs/pbd/crossthread.win.cc
index 5309916ddb..73ff74ddcf 100644
--- a/libs/pbd/crossthread.win.cc
+++ b/libs/pbd/crossthread.win.cc
@@ -152,11 +152,38 @@ CrossThreadChannel::deliver (char msg)
return status;
}
+bool
+CrossThreadChannel::poll_for_request()
+{
+ // windows before Vista has no poll
+ while(true) {
+ fd_set rfds;
+ FD_ZERO(&rfds);
+ FD_SET(receive_socket, &rfds);
+ if ((select(receive_socket+1, &rfds, NULL, NULL, NULL)) < 0) {
+ if (errno == EINTR) {
+ continue;
+ }
+ break;
+ }
+ if(FD_ISSET(receive_socket, &rfds)) {
+ return true;
+ }
+ }
+ return false;
+}
+
int
-CrossThreadChannel::receive (char& msg)
+CrossThreadChannel::receive (char& msg, bool wait)
{
gsize read = 0;
GError *g_error = 0;
+
+ if (wait) {
+ if (!poll_for_request ()) {
+ return -1;
+ }
+ }
// fetch the message from the channel.
GIOStatus g_status = g_io_channel_read_chars (receive_channel, &msg, sizeof(msg), &read, &g_error);