projects
/
ardour.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
remove c99'ness from rsynth.c - should fix #5751
[ardour.git]
/
libs
/
pbd
/
crossthread.cc
diff --git
a/libs/pbd/crossthread.cc
b/libs/pbd/crossthread.cc
index 2bcb444b366ef322c1468231d7efa313d478ba0a..2ffede5163aecc736372818fd82ddb934b2d8d42 100644
(file)
--- a/
libs/pbd/crossthread.cc
+++ b/
libs/pbd/crossthread.cc
@@
-30,7
+30,7
@@
using namespace std;
using namespace PBD;
using namespace Glib;
using namespace PBD;
using namespace Glib;
-CrossThreadChannel::CrossThreadChannel ()
+CrossThreadChannel::CrossThreadChannel (
bool non_blocking
)
{
_ios = 0;
fds[0] = -1;
{
_ios = 0;
fds[0] = -1;
@@
-41,14
+41,16
@@
CrossThreadChannel::CrossThreadChannel ()
return;
}
return;
}
- if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
- error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
- return;
- }
-
- if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
- error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
- return;
+ if (non_blocking) {
+ if (fcntl (fds[0], F_SETFL, O_NONBLOCK)) {
+ error << "cannot set non-blocking mode for x-thread pipe (read) (" << ::strerror (errno) << ')' << endmsg;
+ return;
+ }
+
+ if (fcntl (fds[1], F_SETFL, O_NONBLOCK)) {
+ error << "cannot set non-blocking mode for x-thread pipe (write) (%2)" << ::strerror (errno) << ')' << endmsg;
+ return;
+ }
}
}
}
}
@@
-72,7
+74,7
@@
void
CrossThreadChannel::wakeup ()
{
char c = 0;
CrossThreadChannel::wakeup ()
{
char c = 0;
- ::write (fds[1], &c, 1);
+
(void)
::write (fds[1], &c, 1);
}
RefPtr<IOSource>
}
RefPtr<IOSource>
@@
-102,5
+104,17
@@
CrossThreadChannel::drain (int fd)
{
/* drain selectable fd */
char buf[64];
{
/* drain selectable fd */
char buf[64];
- while (::read (fd, buf, sizeof (buf)) > 0);
+ while (::read (fd, buf, sizeof (buf)) > 0) {};
+}
+
+int
+CrossThreadChannel::deliver (char msg)
+{
+ return ::write (fds[1], &msg, 1);
+}
+
+int
+CrossThreadChannel::receive (char& msg)
+{
+ return ::read (fds[0], &msg, 1);
}
}