Skip to content

Commit 0345ded

Browse files
Introduce IO::Event::WorkerPool for blocking_operation_wait. (#139)
1 parent 4848faf commit 0345ded

File tree

11 files changed

+1067
-2
lines changed

11 files changed

+1067
-2
lines changed

ext/extconf.rb

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,16 @@
5858

5959
have_header("ruby/io/buffer.h")
6060

61+
# Feature detection for blocking operation support
62+
if have_func("rb_fiber_scheduler_blocking_operation_extract")
63+
# Feature detection for pthread support (needed for WorkerPool)
64+
if have_header("pthread.h")
65+
append_cflags(["-DHAVE_IO_EVENT_WORKER_POOL"])
66+
$srcs << "io/event/worker_pool.c"
67+
$srcs << "io/event/worker_pool_test.c"
68+
end
69+
end
70+
6171
if ENV.key?("RUBY_SANITIZE")
6272
$stderr.puts "Enabling sanitizers..."
6373

ext/io/event/event.c

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@ void Init_IO_Event(void)
1414
VALUE IO_Event = rb_define_module_under(rb_cIO, "Event");
1515

1616
Init_IO_Event_Fiber(IO_Event);
17-
17+
18+
#ifdef HAVE_IO_EVENT_WORKER_POOL
19+
Init_IO_Event_WorkerPool(IO_Event);
20+
#endif
21+
1822
VALUE IO_Event_Selector = rb_define_module_under(IO_Event, "Selector");
1923
Init_IO_Event_Selector(IO_Event_Selector);
2024

ext/io/event/event.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,3 +18,7 @@ void Init_IO_Event(void);
1818
#ifdef HAVE_SYS_EVENT_H
1919
#include "selector/kqueue.h"
2020
#endif
21+
22+
#ifdef HAVE_IO_EVENT_WORKER_POOL
23+
#include "worker_pool.h"
24+
#endif

ext/io/event/fiber.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ VALUE IO_Event_Fiber_raise(VALUE fiber, int argc, VALUE *argv) {
3535
#ifndef HAVE_RB_FIBER_CURRENT
3636
static ID id_current;
3737

38-
static VALUE IO_Event_Fiber_current(void) {
38+
VALUE IO_Event_Fiber_current(void) {
3939
return rb_funcall(rb_cFiber, id_current, 0);
4040
}
4141
#endif

0 commit comments

Comments
 (0)