summaryrefslogtreecommitdiff
path: root/thread_win32.c
diff options
context:
space:
mode:
authorusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-15 18:04:13 (GMT)
committerusa <usa@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2011-06-15 18:04:13 (GMT)
commita8bdd28d10c2c5981e944e945eed95f6c4ad44bc (patch)
treeed9f4c66c96113c5832cbc2d0da018ef6af31ce4 /thread_win32.c
parent3eb1b472e26d65664b96ca261891cebada6fa03f (diff)
* thread.c (do_select): Windows: no need to poll if select(2) is
cancelable. * thread_win32.c (native_fd_select): new function to make select(2) cancelable. * thread_win32.c (rb_w32_check_interrupt): new function for checking interrupt. * win32/win32.c (rb_w32_select_with_thread): new function. cancelable select(2). * win32/win32.c (rb_w32_select): use above function internally. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32107 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread_win32.c')
-rw-r--r--thread_win32.c28
1 files changed, 28 insertions, 0 deletions
diff --git a/thread_win32.c b/thread_win32.c
index 668d94b..172c942 100644
--- a/thread_win32.c
+++ b/thread_win32.c
@@ -673,6 +673,34 @@ native_thread_apply_priority(rb_thread_t *th)
#endif /* USE_NATIVE_THREAD_PRIORITY */
+int rb_w32_select_with_thread(int, fd_set *, fd_set *, fd_set *, struct timeval *, void *); /* @internal */
+
+static int
+native_fd_select(int n, rb_fdset_t *readfds, rb_fdset_t *writefds, rb_fdset_t *exceptfds, struct timeval *timeout, rb_thread_t *th)
+{
+ fd_set *r = NULL, *w = NULL, *e = NULL;
+ if (readfds) {
+ rb_fd_resize(n - 1, readfds);
+ r = rb_fd_ptr(readfds);
+ }
+ if (writefds) {
+ rb_fd_resize(n - 1, writefds);
+ w = rb_fd_ptr(writefds);
+ }
+ if (exceptfds) {
+ rb_fd_resize(n - 1, exceptfds);
+ e = rb_fd_ptr(exceptfds);
+ }
+ return rb_w32_select_with_thread(n, r, w, e, timeout, th);
+}
+
+/* @internal */
+int
+rb_w32_check_interrupt(rb_thread_t *th)
+{
+ return w32_wait_events(0, 0, 0, th);
+}
+
static void
ubf_handle(void *ptr)
{