aboutsummaryrefslogtreecommitdiffhomepage
path: root/input_common.cpp
diff options
context:
space:
mode:
authorGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-04-29 17:03:00 -0700
committerGravatar ridiculousfish <corydoras@ridiculousfish.com>2014-04-29 17:03:00 -0700
commit7a5a277c294f733feb60e84e6132940467edb374 (patch)
tree9e7f4e6c00f0cda198fc3c089c3f3c90228692da /input_common.cpp
parent38da76804e8e1c0e97ba4f59711b64f0637ced50 (diff)
Implement universal variable deletion. Adopt shared memory uvar notification.
Diffstat (limited to 'input_common.cpp')
-rw-r--r--input_common.cpp33
1 files changed, 28 insertions, 5 deletions
diff --git a/input_common.cpp b/input_common.cpp
index d26f30b9..5b91073f 100644
--- a/input_common.cpp
+++ b/input_common.cpp
@@ -96,7 +96,7 @@ static wint_t readb()
input_flush_callbacks();
fd_set fdset;
- int fd_max=0;
+ int fd_max = 0;
int ioport = iothread_port();
int res;
@@ -105,15 +105,32 @@ static wint_t readb()
if (env_universal_server.fd > 0)
{
FD_SET(env_universal_server.fd, &fdset);
- if (fd_max < env_universal_server.fd) fd_max = env_universal_server.fd;
+ fd_max = maxi(fd_max, env_universal_server.fd);
}
if (ioport > 0)
{
FD_SET(ioport, &fdset);
- if (fd_max < ioport) fd_max = ioport;
+ fd_max = maxi(fd_max, ioport);
+ }
+
+ /* Get our uvar notifier */
+ universal_notifier_t &notifier = universal_notifier_t::default_notifier();
+
+ /* Get the suggested delay */
+ struct timeval tv = {};
+ const unsigned long usecs_delay = notifier.usec_delay_between_polls();
+ if (usecs_delay > 0)
+ {
+ unsigned long usecs_per_sec = 1000000;
+ tv.tv_sec = (int)(usecs_delay / usecs_per_sec);
+ tv.tv_usec = (int)(usecs_delay % usecs_per_sec);
+ }
+
+ res = select(fd_max + 1, &fdset, 0, 0, usecs_delay > 0 ? &tv : NULL);
+ if (res == 0)
+ {
+ fprintf(stderr, "ping\n");
}
-
- res = select(fd_max + 1, &fdset, 0, 0, 0);
if (res==-1)
{
switch (errno)
@@ -162,6 +179,12 @@ static wint_t readb()
return lookahead_pop();
}
}
+
+ if (notifier.poll())
+ {
+ fprintf(stderr, "Change note\n");
+ env_universal_barrier();
+ }
if (ioport > 0 && FD_ISSET(ioport, &fdset))
{