polyphony 0.45.5 → 0.47.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +2 -0
- data/.gitmodules +0 -0
- data/CHANGELOG.md +23 -0
- data/Gemfile.lock +1 -1
- data/README.md +3 -3
- data/Rakefile +1 -1
- data/TODO.md +21 -22
- data/bin/test +4 -0
- data/examples/core/enumerable.rb +64 -0
- data/examples/performance/fiber_resume.rb +43 -0
- data/examples/performance/fiber_transfer.rb +13 -4
- data/examples/performance/thread-vs-fiber/compare.rb +59 -0
- data/examples/performance/thread-vs-fiber/em_server.rb +33 -0
- data/examples/performance/thread-vs-fiber/polyphony_server.rb +10 -21
- data/examples/performance/thread-vs-fiber/threaded_server.rb +22 -15
- data/examples/performance/thread_switch.rb +44 -0
- data/ext/liburing/liburing.h +585 -0
- data/ext/liburing/liburing/README.md +4 -0
- data/ext/liburing/liburing/barrier.h +73 -0
- data/ext/liburing/liburing/compat.h +15 -0
- data/ext/liburing/liburing/io_uring.h +343 -0
- data/ext/liburing/queue.c +333 -0
- data/ext/liburing/register.c +187 -0
- data/ext/liburing/setup.c +210 -0
- data/ext/liburing/syscall.c +54 -0
- data/ext/liburing/syscall.h +18 -0
- data/ext/polyphony/backend.h +0 -14
- data/ext/polyphony/backend_common.h +129 -0
- data/ext/polyphony/backend_io_uring.c +995 -0
- data/ext/polyphony/backend_io_uring_context.c +74 -0
- data/ext/polyphony/backend_io_uring_context.h +53 -0
- data/ext/polyphony/{libev_backend.c → backend_libev.c} +304 -294
- data/ext/polyphony/event.c +1 -1
- data/ext/polyphony/extconf.rb +31 -13
- data/ext/polyphony/fiber.c +35 -24
- data/ext/polyphony/libev.c +4 -0
- data/ext/polyphony/libev.h +8 -2
- data/ext/polyphony/liburing.c +8 -0
- data/ext/polyphony/playground.c +51 -0
- data/ext/polyphony/polyphony.c +8 -5
- data/ext/polyphony/polyphony.h +23 -19
- data/ext/polyphony/polyphony_ext.c +10 -4
- data/ext/polyphony/queue.c +100 -35
- data/ext/polyphony/thread.c +10 -10
- data/lib/polyphony/adapters/trace.rb +2 -2
- data/lib/polyphony/core/exceptions.rb +0 -4
- data/lib/polyphony/core/global_api.rb +45 -21
- data/lib/polyphony/core/resource_pool.rb +12 -1
- data/lib/polyphony/extensions/core.rb +9 -15
- data/lib/polyphony/extensions/debug.rb +13 -0
- data/lib/polyphony/extensions/fiber.rb +8 -4
- data/lib/polyphony/extensions/openssl.rb +6 -0
- data/lib/polyphony/extensions/socket.rb +73 -10
- data/lib/polyphony/version.rb +1 -1
- data/test/helper.rb +36 -4
- data/test/io_uring_test.rb +55 -0
- data/test/stress.rb +4 -1
- data/test/test_backend.rb +63 -6
- data/test/test_ext.rb +1 -2
- data/test/test_fiber.rb +55 -20
- data/test/test_global_api.rb +107 -35
- data/test/test_queue.rb +117 -0
- data/test/test_resource_pool.rb +21 -0
- data/test/test_socket.rb +2 -2
- data/test/test_throttler.rb +3 -6
- data/test/test_trace.rb +7 -5
- metadata +28 -3
data/ext/polyphony/event.c
CHANGED
@@ -69,7 +69,7 @@ VALUE Event_await(VALUE self) {
|
|
69
69
|
VALUE switchpoint_result = __BACKEND__.wait_event(backend, Qnil);
|
70
70
|
event->waiting_fiber = Qnil;
|
71
71
|
|
72
|
-
|
72
|
+
RAISE_IF_EXCEPTION(switchpoint_result);
|
73
73
|
RB_GC_GUARD(backend);
|
74
74
|
RB_GC_GUARD(switchpoint_result);
|
75
75
|
|
data/ext/polyphony/extconf.rb
CHANGED
@@ -1,20 +1,38 @@
|
|
1
1
|
# frozen_string_literal: true
|
2
2
|
|
3
|
-
require
|
3
|
+
require 'rubygems'
|
4
|
+
require 'mkmf'
|
4
5
|
|
5
|
-
|
6
|
+
use_liburing = false
|
7
|
+
force_use_libev = ENV['POLYPHONY_USE_LIBEV'] != nil
|
6
8
|
|
7
|
-
|
9
|
+
if !force_use_libev && RUBY_PLATFORM =~ /linux/ && `uname -sr` =~ /Linux 5\.([\d+])/
|
10
|
+
kernel_minor_version = $1.gsub('.', '').to_i
|
11
|
+
use_liburing = kernel_minor_version >= 6
|
12
|
+
end
|
8
13
|
|
9
|
-
|
10
|
-
$defs << "-
|
11
|
-
$
|
12
|
-
|
13
|
-
$defs << "-
|
14
|
-
$defs <<
|
15
|
-
$defs <<
|
14
|
+
if use_liburing
|
15
|
+
$defs << "-DPOLYPHONY_BACKEND_LIBURING"
|
16
|
+
$CFLAGS << " -Wno-pointer-arith"
|
17
|
+
else
|
18
|
+
$defs << "-DPOLYPHONY_BACKEND_LIBEV"
|
19
|
+
$defs << '-DEV_USE_LINUXAIO' if have_header('linux/aio_abi.h')
|
20
|
+
$defs << '-DEV_USE_SELECT' if have_header('sys/select.h')
|
21
|
+
$defs << '-DEV_USE_POLL' if have_type('port_event_t', 'poll.h')
|
22
|
+
$defs << '-DEV_USE_EPOLL' if have_header('sys/epoll.h')
|
23
|
+
$defs << '-DEV_USE_KQUEUE' if have_header('sys/event.h') && have_header('sys/queue.h')
|
24
|
+
$defs << '-DEV_USE_PORT' if have_type('port_event_t', 'port.h')
|
25
|
+
$defs << '-DHAVE_SYS_RESOURCE_H' if have_header('sys/resource.h')
|
26
|
+
$CFLAGS << " -Wno-comment"
|
27
|
+
$CFLAGS << " -Wno-unused-result"
|
28
|
+
$CFLAGS << " -Wno-dangling-else"
|
29
|
+
$CFLAGS << " -Wno-parentheses"
|
30
|
+
end
|
16
31
|
|
17
|
-
|
32
|
+
$defs << '-DPOLYPHONY_PLAYGROUND' if ENV['POLYPHONY_PLAYGROUND']
|
18
33
|
|
19
|
-
|
20
|
-
|
34
|
+
CONFIG['optflags'] << ' -fno-strict-aliasing' unless RUBY_PLATFORM =~ /mswin/
|
35
|
+
|
36
|
+
|
37
|
+
dir_config 'polyphony_ext'
|
38
|
+
create_makefile 'polyphony_ext'
|
data/ext/polyphony/fiber.c
CHANGED
@@ -3,6 +3,7 @@
|
|
3
3
|
ID ID_fiber_trace;
|
4
4
|
ID ID_ivar_auto_watcher;
|
5
5
|
ID ID_ivar_mailbox;
|
6
|
+
ID ID_ivar_result;
|
6
7
|
ID ID_ivar_waiting_fibers;
|
7
8
|
|
8
9
|
VALUE SYM_dead;
|
@@ -11,8 +12,8 @@ VALUE SYM_runnable;
|
|
11
12
|
VALUE SYM_waiting;
|
12
13
|
|
13
14
|
VALUE SYM_fiber_create;
|
14
|
-
VALUE
|
15
|
-
VALUE
|
15
|
+
VALUE SYM_fiber_event_poll_enter;
|
16
|
+
VALUE SYM_fiber_event_poll_leave;
|
16
17
|
VALUE SYM_fiber_run;
|
17
18
|
VALUE SYM_fiber_schedule;
|
18
19
|
VALUE SYM_fiber_switchpoint;
|
@@ -20,9 +21,9 @@ VALUE SYM_fiber_terminate;
|
|
20
21
|
|
21
22
|
static VALUE Fiber_safe_transfer(int argc, VALUE *argv, VALUE self) {
|
22
23
|
VALUE arg = (argc == 0) ? Qnil : argv[0];
|
23
|
-
VALUE ret =
|
24
|
+
VALUE ret = FIBER_TRANSFER(self, arg);
|
24
25
|
|
25
|
-
|
26
|
+
RAISE_IF_EXCEPTION(ret);
|
26
27
|
RB_GC_GUARD(ret);
|
27
28
|
return ret;
|
28
29
|
}
|
@@ -41,8 +42,8 @@ inline VALUE Fiber_auto_watcher(VALUE self) {
|
|
41
42
|
void Fiber_make_runnable(VALUE fiber, VALUE value) {
|
42
43
|
VALUE thread = rb_ivar_get(fiber, ID_ivar_thread);
|
43
44
|
if (thread == Qnil) {
|
44
|
-
|
45
|
-
rb_warn("No thread set for fiber");
|
45
|
+
rb_raise(rb_eRuntimeError, "No thread set for fiber");
|
46
|
+
// rb_warn("No thread set for fiber");
|
46
47
|
return;
|
47
48
|
}
|
48
49
|
|
@@ -52,8 +53,8 @@ void Fiber_make_runnable(VALUE fiber, VALUE value) {
|
|
52
53
|
void Fiber_make_runnable_with_priority(VALUE fiber, VALUE value) {
|
53
54
|
VALUE thread = rb_ivar_get(fiber, ID_ivar_thread);
|
54
55
|
if (thread == Qnil) {
|
55
|
-
|
56
|
-
rb_warn("No thread set for fiber");
|
56
|
+
rb_raise(rb_eRuntimeError, "No thread set for fiber");
|
57
|
+
// rb_warn("No thread set for fiber");
|
57
58
|
return;
|
58
59
|
}
|
59
60
|
|
@@ -88,7 +89,7 @@ VALUE Fiber_await(VALUE self) {
|
|
88
89
|
// @running set to nil
|
89
90
|
if (rb_ivar_get(self, ID_ivar_running) == Qfalse) {
|
90
91
|
result = rb_ivar_get(self, ID_ivar_result);
|
91
|
-
|
92
|
+
RAISE_IF_EXCEPTION(result);
|
92
93
|
return result;
|
93
94
|
}
|
94
95
|
|
@@ -103,7 +104,7 @@ VALUE Fiber_await(VALUE self) {
|
|
103
104
|
result = Thread_switch_fiber(rb_thread_current());
|
104
105
|
|
105
106
|
rb_hash_delete(waiting_fibers, fiber);
|
106
|
-
|
107
|
+
RAISE_IF_EXCEPTION(result);
|
107
108
|
RB_GC_GUARD(result);
|
108
109
|
return result;
|
109
110
|
}
|
@@ -127,6 +128,15 @@ VALUE Fiber_receive(VALUE self) {
|
|
127
128
|
return Queue_shift(mailbox);
|
128
129
|
}
|
129
130
|
|
131
|
+
VALUE Fiber_mailbox(VALUE self) {
|
132
|
+
VALUE mailbox = rb_ivar_get(self, ID_ivar_mailbox);
|
133
|
+
if (mailbox == Qnil) {
|
134
|
+
mailbox = rb_funcall(cQueue, ID_new, 0);
|
135
|
+
rb_ivar_set(self, ID_ivar_mailbox, mailbox);
|
136
|
+
}
|
137
|
+
return mailbox;
|
138
|
+
}
|
139
|
+
|
130
140
|
VALUE Fiber_receive_all_pending(VALUE self) {
|
131
141
|
VALUE mailbox = rb_ivar_get(self, ID_ivar_mailbox);
|
132
142
|
return (mailbox == Qnil) ? rb_ary_new() : Queue_shift_all(mailbox);
|
@@ -145,9 +155,9 @@ void Init_Fiber() {
|
|
145
155
|
|
146
156
|
rb_define_method(cFiber, "<<", Fiber_send, 1);
|
147
157
|
rb_define_method(cFiber, "send", Fiber_send, 1);
|
148
|
-
|
149
158
|
rb_define_method(cFiber, "receive", Fiber_receive, 0);
|
150
159
|
rb_define_method(cFiber, "receive_all_pending", Fiber_receive_all_pending, 0);
|
160
|
+
rb_define_method(cFiber, "mailbox", Fiber_mailbox, 0);
|
151
161
|
|
152
162
|
SYM_dead = ID2SYM(rb_intern("dead"));
|
153
163
|
SYM_running = ID2SYM(rb_intern("running"));
|
@@ -158,22 +168,23 @@ void Init_Fiber() {
|
|
158
168
|
rb_global_variable(&SYM_runnable);
|
159
169
|
rb_global_variable(&SYM_waiting);
|
160
170
|
|
161
|
-
ID_fiber_trace
|
162
|
-
ID_ivar_auto_watcher
|
163
|
-
ID_ivar_mailbox
|
164
|
-
|
171
|
+
ID_fiber_trace = rb_intern("__fiber_trace__");
|
172
|
+
ID_ivar_auto_watcher = rb_intern("@auto_watcher");
|
173
|
+
ID_ivar_mailbox = rb_intern("@mailbox");
|
174
|
+
ID_ivar_result = rb_intern("@result");
|
175
|
+
ID_ivar_waiting_fibers = rb_intern("@waiting_fibers");
|
165
176
|
|
166
|
-
SYM_fiber_create
|
167
|
-
|
168
|
-
|
169
|
-
SYM_fiber_run
|
170
|
-
SYM_fiber_schedule
|
171
|
-
SYM_fiber_switchpoint
|
172
|
-
SYM_fiber_terminate
|
177
|
+
SYM_fiber_create = ID2SYM(rb_intern("fiber_create"));
|
178
|
+
SYM_fiber_event_poll_enter = ID2SYM(rb_intern("fiber_event_poll_enter"));
|
179
|
+
SYM_fiber_event_poll_leave = ID2SYM(rb_intern("fiber_event_poll_leave"));
|
180
|
+
SYM_fiber_run = ID2SYM(rb_intern("fiber_run"));
|
181
|
+
SYM_fiber_schedule = ID2SYM(rb_intern("fiber_schedule"));
|
182
|
+
SYM_fiber_switchpoint = ID2SYM(rb_intern("fiber_switchpoint"));
|
183
|
+
SYM_fiber_terminate = ID2SYM(rb_intern("fiber_terminate"));
|
173
184
|
|
174
185
|
rb_global_variable(&SYM_fiber_create);
|
175
|
-
rb_global_variable(&
|
176
|
-
rb_global_variable(&
|
186
|
+
rb_global_variable(&SYM_fiber_event_poll_enter);
|
187
|
+
rb_global_variable(&SYM_fiber_event_poll_leave);
|
177
188
|
rb_global_variable(&SYM_fiber_run);
|
178
189
|
rb_global_variable(&SYM_fiber_schedule);
|
179
190
|
rb_global_variable(&SYM_fiber_switchpoint);
|
data/ext/polyphony/libev.c
CHANGED
data/ext/polyphony/libev.h
CHANGED
@@ -1,4 +1,8 @@
|
|
1
|
-
#define EV_STANDALONE
|
1
|
+
#define EV_STANDALONE
|
2
|
+
|
3
|
+
#ifdef POLYPHONY_BACKEND_LIBEV
|
4
|
+
|
5
|
+
/* keeps ev from requiring config.h */
|
2
6
|
|
3
7
|
#ifdef _WIN32
|
4
8
|
#define EV_SELECT_IS_WINSOCKET 1
|
@@ -6,4 +10,6 @@
|
|
6
10
|
#define EV_USE_REALTIME 0
|
7
11
|
#endif
|
8
12
|
|
9
|
-
#include "../libev/ev.h"
|
13
|
+
#include "../libev/ev.h"
|
14
|
+
|
15
|
+
#endif // POLYPHONY_BACKEND_LIBEV
|
@@ -0,0 +1,51 @@
|
|
1
|
+
#ifdef POLYPHONY_PLAYGROUND
|
2
|
+
|
3
|
+
#include <netdb.h>
|
4
|
+
#include <sys/socket.h>
|
5
|
+
#include <sys/uio.h>
|
6
|
+
#include <unistd.h>
|
7
|
+
#include <fcntl.h>
|
8
|
+
#include <netinet/in.h>
|
9
|
+
#include <arpa/inet.h>
|
10
|
+
|
11
|
+
#include "polyphony.h"
|
12
|
+
#include "../liburing/liburing.h"
|
13
|
+
#include "ruby/thread.h"
|
14
|
+
|
15
|
+
#include <poll.h>
|
16
|
+
#include <sys/types.h>
|
17
|
+
#include <sys/eventfd.h>
|
18
|
+
#include <sys/wait.h>
|
19
|
+
#include <time.h>
|
20
|
+
#include <stdnoreturn.h>
|
21
|
+
|
22
|
+
void print(struct io_uring *ring, const char *str) {
|
23
|
+
struct io_uring_sqe *sqe = io_uring_get_sqe(ring);
|
24
|
+
io_uring_prep_write(sqe, 1, str, strlen(str), -1);
|
25
|
+
io_uring_sqe_set_data(sqe, (void *)42);
|
26
|
+
// io_uring_sqe_set_flags(sqe, IOSQE_ASYNC);
|
27
|
+
io_uring_submit(ring);
|
28
|
+
|
29
|
+
struct io_uring_cqe *cqe;
|
30
|
+
int ret = __io_uring_get_cqe(ring, &cqe, 0, 1, NULL);
|
31
|
+
if (ret != 0) {
|
32
|
+
printf("ret: %d\n", ret);
|
33
|
+
exit(1);
|
34
|
+
}
|
35
|
+
printf(" cqe res: %d\n", cqe->res);
|
36
|
+
io_uring_cqe_seen(ring, cqe);
|
37
|
+
}
|
38
|
+
|
39
|
+
noreturn void playground() {
|
40
|
+
struct io_uring ring;
|
41
|
+
io_uring_queue_init(1024, &ring, 0);
|
42
|
+
|
43
|
+
for (int i = 0; i < 10; i++) {
|
44
|
+
print(&ring, "hi\n");
|
45
|
+
}
|
46
|
+
|
47
|
+
io_uring_queue_exit(&ring);
|
48
|
+
exit(0);
|
49
|
+
}
|
50
|
+
|
51
|
+
#endif //POLYPHONY_PLAYGROUND
|
data/ext/polyphony/polyphony.c
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
#include "polyphony.h"
|
2
2
|
|
3
3
|
VALUE mPolyphony;
|
4
|
+
VALUE cTimeoutException;
|
4
5
|
|
5
6
|
ID ID_call;
|
6
7
|
ID ID_caller;
|
@@ -9,7 +10,7 @@ ID ID_each;
|
|
9
10
|
ID ID_inspect;
|
10
11
|
ID ID_invoke;
|
11
12
|
ID ID_new;
|
12
|
-
ID
|
13
|
+
ID ID_ivar_io;
|
13
14
|
ID ID_ivar_runnable;
|
14
15
|
ID ID_ivar_running;
|
15
16
|
ID ID_ivar_thread;
|
@@ -29,7 +30,7 @@ VALUE Polyphony_snooze(VALUE self) {
|
|
29
30
|
|
30
31
|
Fiber_make_runnable(fiber, Qnil);
|
31
32
|
ret = Thread_switch_fiber(rb_thread_current());
|
32
|
-
|
33
|
+
RAISE_IF_EXCEPTION(ret);
|
33
34
|
RB_GC_GUARD(ret);
|
34
35
|
return ret;
|
35
36
|
}
|
@@ -37,7 +38,7 @@ VALUE Polyphony_snooze(VALUE self) {
|
|
37
38
|
static VALUE Polyphony_suspend(VALUE self) {
|
38
39
|
VALUE ret = Thread_switch_fiber(rb_thread_current());
|
39
40
|
|
40
|
-
|
41
|
+
RAISE_IF_EXCEPTION(ret);
|
41
42
|
RB_GC_GUARD(ret);
|
42
43
|
return ret;
|
43
44
|
}
|
@@ -55,14 +56,16 @@ void Init_Polyphony() {
|
|
55
56
|
rb_define_global_function("snooze", Polyphony_snooze, 0);
|
56
57
|
rb_define_global_function("suspend", Polyphony_suspend, 0);
|
57
58
|
|
59
|
+
cTimeoutException = rb_define_class_under(mPolyphony, "TimeoutException", rb_eException);
|
60
|
+
|
58
61
|
ID_call = rb_intern("call");
|
59
62
|
ID_caller = rb_intern("caller");
|
60
63
|
ID_clear = rb_intern("clear");
|
61
64
|
ID_each = rb_intern("each");
|
62
65
|
ID_inspect = rb_intern("inspect");
|
63
66
|
ID_invoke = rb_intern("invoke");
|
64
|
-
|
65
|
-
ID_ivar_runnable = rb_intern("runnable");
|
67
|
+
ID_ivar_io = rb_intern("@io");
|
68
|
+
ID_ivar_runnable = rb_intern("@runnable");
|
66
69
|
ID_ivar_running = rb_intern("@running");
|
67
70
|
ID_ivar_thread = rb_intern("@thread");
|
68
71
|
ID_new = rb_intern("new");
|
data/ext/polyphony/polyphony.h
CHANGED
@@ -1,29 +1,36 @@
|
|
1
1
|
#ifndef POLYPHONY_H
|
2
2
|
#define POLYPHONY_H
|
3
3
|
|
4
|
+
#include <execinfo.h>
|
5
|
+
|
4
6
|
#include "ruby.h"
|
5
|
-
#include "ruby/io.h"
|
6
|
-
#include "libev.h"
|
7
7
|
#include "backend.h"
|
8
8
|
#include "runqueue_ring_buffer.h"
|
9
9
|
|
10
10
|
// debugging
|
11
11
|
#define OBJ_ID(obj) (NUM2LONG(rb_funcall(obj, rb_intern("object_id"), 0)))
|
12
|
-
#define INSPECT(str, obj) { printf(str); VALUE s = rb_funcall(obj, rb_intern("inspect"), 0); printf("%s\n", StringValueCStr(s)); }
|
12
|
+
#define INSPECT(str, obj) { printf(str); VALUE s = rb_funcall(obj, rb_intern("inspect"), 0); printf(": %s\n", StringValueCStr(s)); }
|
13
13
|
#define TRACE_CALLER() { VALUE c = rb_funcall(rb_mKernel, rb_intern("caller"), 0); INSPECT("caller: ", c); }
|
14
|
+
#define TRACE_C_STACK() { \
|
15
|
+
void *entries[10]; \
|
16
|
+
size_t size = backtrace(entries, 10); \
|
17
|
+
char **strings = backtrace_symbols(entries, size); \
|
18
|
+
for (unsigned long i = 0; i < size; i++) printf("%s\n", strings[i]); \
|
19
|
+
free(strings); \
|
20
|
+
}
|
14
21
|
|
15
22
|
// tracing
|
16
23
|
#define TRACE(...) rb_funcall(rb_cObject, ID_fiber_trace, __VA_ARGS__)
|
17
|
-
#define COND_TRACE(...) if (__tracing_enabled__) {
|
18
|
-
TRACE(__VA_ARGS__); \
|
19
|
-
}
|
24
|
+
#define COND_TRACE(...) if (__tracing_enabled__) { TRACE(__VA_ARGS__); }
|
20
25
|
|
26
|
+
// exceptions
|
21
27
|
#define TEST_EXCEPTION(ret) (RTEST(rb_obj_is_kind_of(ret, rb_eException)))
|
22
|
-
|
23
28
|
#define RAISE_EXCEPTION(e) rb_funcall(e, ID_invoke, 0);
|
24
|
-
#define
|
25
|
-
|
26
|
-
|
29
|
+
#define RAISE_IF_EXCEPTION(ret) if (RTEST(rb_obj_is_kind_of(ret, rb_eException))) { RAISE_EXCEPTION(ret); }
|
30
|
+
#define RAISE_IF_NOT_NIL(ret) if (ret != Qnil) { RAISE_EXCEPTION(ret); }
|
31
|
+
|
32
|
+
// Fiber#transfer
|
33
|
+
#define FIBER_TRANSFER(fiber, value) rb_funcall(fiber, ID_transfer, 1, value)
|
27
34
|
|
28
35
|
extern backend_interface_t backend_interface;
|
29
36
|
#define __BACKEND__ (backend_interface)
|
@@ -32,6 +39,7 @@ extern VALUE mPolyphony;
|
|
32
39
|
extern VALUE cQueue;
|
33
40
|
extern VALUE cEvent;
|
34
41
|
extern VALUE cRunqueue;
|
42
|
+
extern VALUE cTimeoutException;
|
35
43
|
|
36
44
|
extern ID ID_call;
|
37
45
|
extern ID ID_caller;
|
@@ -41,7 +49,7 @@ extern ID ID_fiber_trace;
|
|
41
49
|
extern ID ID_inspect;
|
42
50
|
extern ID ID_invoke;
|
43
51
|
extern ID ID_ivar_backend;
|
44
|
-
extern ID
|
52
|
+
extern ID ID_ivar_io;
|
45
53
|
extern ID ID_ivar_runnable;
|
46
54
|
extern ID ID_ivar_running;
|
47
55
|
extern ID ID_ivar_thread;
|
@@ -53,8 +61,8 @@ extern ID ID_switch_fiber;
|
|
53
61
|
extern ID ID_transfer;
|
54
62
|
|
55
63
|
extern VALUE SYM_fiber_create;
|
56
|
-
extern VALUE
|
57
|
-
extern VALUE
|
64
|
+
extern VALUE SYM_fiber_event_poll_enter;
|
65
|
+
extern VALUE SYM_fiber_event_poll_leave;
|
58
66
|
extern VALUE SYM_fiber_run;
|
59
67
|
extern VALUE SYM_fiber_schedule;
|
60
68
|
extern VALUE SYM_fiber_switchpoint;
|
@@ -75,12 +83,6 @@ VALUE Queue_push(VALUE self, VALUE value);
|
|
75
83
|
VALUE Queue_unshift(VALUE self, VALUE value);
|
76
84
|
VALUE Queue_shift(VALUE self);
|
77
85
|
VALUE Queue_shift_all(VALUE self);
|
78
|
-
VALUE Queue_shift_no_wait(VALUE self);
|
79
|
-
VALUE Queue_clear(VALUE self);
|
80
|
-
VALUE Queue_delete(VALUE self, VALUE value);
|
81
|
-
long Queue_len(VALUE self);
|
82
|
-
void Queue_trace(VALUE self);
|
83
|
-
|
84
86
|
|
85
87
|
void Runqueue_push(VALUE self, VALUE fiber, VALUE value, int reschedule);
|
86
88
|
void Runqueue_unshift(VALUE self, VALUE fiber, VALUE value, int reschedule);
|
@@ -94,4 +96,6 @@ VALUE Thread_schedule_fiber(VALUE thread, VALUE fiber, VALUE value);
|
|
94
96
|
VALUE Thread_schedule_fiber_with_priority(VALUE thread, VALUE fiber, VALUE value);
|
95
97
|
VALUE Thread_switch_fiber(VALUE thread);
|
96
98
|
|
99
|
+
VALUE Polyphony_snooze(VALUE self);
|
100
|
+
|
97
101
|
#endif /* POLYPHONY_H */
|
@@ -2,23 +2,29 @@
|
|
2
2
|
|
3
3
|
void Init_Fiber();
|
4
4
|
void Init_Polyphony();
|
5
|
-
void
|
5
|
+
void Init_Backend();
|
6
6
|
void Init_Queue();
|
7
7
|
void Init_Event();
|
8
8
|
void Init_Runqueue();
|
9
9
|
void Init_Thread();
|
10
10
|
void Init_Tracing();
|
11
11
|
|
12
|
-
|
13
|
-
|
12
|
+
#ifdef POLYPHONY_PLAYGROUND
|
13
|
+
extern void playground();
|
14
|
+
#endif
|
14
15
|
|
16
|
+
void Init_polyphony_ext() {
|
15
17
|
Init_Polyphony();
|
16
18
|
|
17
|
-
|
19
|
+
Init_Backend();
|
18
20
|
Init_Queue();
|
19
21
|
Init_Event();
|
20
22
|
Init_Runqueue();
|
21
23
|
Init_Fiber();
|
22
24
|
Init_Thread();
|
23
25
|
Init_Tracing();
|
26
|
+
|
27
|
+
#ifdef POLYPHONY_PLAYGROUND
|
28
|
+
playground();
|
29
|
+
#endif
|
24
30
|
}
|