polyphony 0.52.0 → 0.55.0
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 +1 -1
- data/.gitignore +3 -1
- data/CHANGELOG.md +45 -22
- data/Gemfile.lock +3 -1
- data/TODO.md +36 -11
- data/examples/core/queue.rb +19 -0
- data/examples/io/echo_server.rb +1 -0
- data/examples/io/https_server.rb +30 -0
- data/examples/io/stdio.rb +8 -0
- data/examples/io/tcp_proxy.rb +2 -2
- data/ext/polyphony/backend_common.h +10 -10
- data/ext/polyphony/backend_io_uring.c +251 -85
- data/ext/polyphony/backend_io_uring_context.c +15 -2
- data/ext/polyphony/backend_io_uring_context.h +12 -11
- data/ext/polyphony/backend_libev.c +165 -24
- data/ext/polyphony/extconf.rb +3 -1
- data/ext/polyphony/polyphony.c +10 -2
- data/ext/polyphony/polyphony.h +5 -0
- data/ext/polyphony/polyphony_ext.c +3 -0
- data/ext/polyphony/runqueue.c +29 -1
- data/ext/polyphony/socket_extensions.c +33 -0
- data/ext/polyphony/thread.c +22 -6
- data/lib/polyphony/core/sync.rb +8 -0
- data/lib/polyphony/extensions/io.rb +8 -0
- data/lib/polyphony/extensions/openssl.rb +24 -17
- data/lib/polyphony/extensions/socket.rb +30 -35
- data/lib/polyphony/version.rb +1 -1
- data/polyphony.gemspec +1 -0
- data/test/helper.rb +3 -3
- data/test/test_backend.rb +164 -1
- data/test/test_fiber.rb +0 -1
- data/test/test_io.rb +6 -3
- data/test/test_signal.rb +1 -1
- data/test/test_sync.rb +43 -0
- data/test/test_thread.rb +4 -0
- data/test/test_thread_pool.rb +1 -1
- data/test/test_timer.rb +13 -7
- metadata +20 -2
data/test/test_fiber.rb
CHANGED
data/test/test_io.rb
CHANGED
@@ -98,8 +98,10 @@ class IOTest < MiniTest::Test
|
|
98
98
|
|
99
99
|
buf = []
|
100
100
|
f = spin do
|
101
|
+
peer = receive
|
101
102
|
while (l = i.gets)
|
102
103
|
buf << l
|
104
|
+
peer << true
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
@@ -107,11 +109,12 @@ class IOTest < MiniTest::Test
|
|
107
109
|
assert_equal [], buf
|
108
110
|
|
109
111
|
o << 'fab'
|
110
|
-
|
112
|
+
f << Fiber.current
|
113
|
+
sleep 0.05
|
111
114
|
assert_equal [], buf
|
112
115
|
|
113
116
|
o << "ulous\n"
|
114
|
-
|
117
|
+
receive
|
115
118
|
assert_equal ["fabulous\n"], buf
|
116
119
|
|
117
120
|
o.close
|
@@ -287,7 +290,7 @@ class IOClassMethodsTest < MiniTest::Test
|
|
287
290
|
end
|
288
291
|
|
289
292
|
def test_foreach
|
290
|
-
skip
|
293
|
+
skip 'IO.foreach is not yet implemented'
|
291
294
|
lines = []
|
292
295
|
IO.foreach(__FILE__) { |l| lines << l }
|
293
296
|
assert_equal "# frozen_string_literal: true\n", lines[0]
|
data/test/test_signal.rb
CHANGED
data/test/test_sync.rb
CHANGED
@@ -70,4 +70,47 @@ class MutexTest < MiniTest::Test
|
|
70
70
|
Fiber.current.await_all_children
|
71
71
|
assert_equal [:bar, :foo], buf
|
72
72
|
end
|
73
|
+
|
74
|
+
def test_owned?
|
75
|
+
buf = []
|
76
|
+
lock = Polyphony::Mutex.new
|
77
|
+
(1..3).each do |i|
|
78
|
+
spin do
|
79
|
+
lock.synchronize do
|
80
|
+
buf << ">> #{i}"
|
81
|
+
buf << [i, lock.owned?]
|
82
|
+
sleep(rand * 0.05)
|
83
|
+
buf << "<< #{i}"
|
84
|
+
end
|
85
|
+
buf << [i, lock.owned?]
|
86
|
+
end
|
87
|
+
end
|
88
|
+
|
89
|
+
Fiber.current.await_all_children
|
90
|
+
assert_equal ['>> 1', [1, true], '<< 1', [1, false], '>> 2', [2, true], '<< 2', [2, false], '>> 3', [3, true], '<< 3', [3, false]], buf
|
91
|
+
end
|
92
|
+
|
93
|
+
def test_locked?
|
94
|
+
lock = Polyphony::Mutex.new
|
95
|
+
a = spin do
|
96
|
+
sender = receive
|
97
|
+
lock.synchronize do
|
98
|
+
sender << 'pong'
|
99
|
+
receive
|
100
|
+
end
|
101
|
+
sender << 'pong'
|
102
|
+
end
|
103
|
+
|
104
|
+
snooze
|
105
|
+
assert !lock.locked?
|
106
|
+
a << Fiber.current
|
107
|
+
|
108
|
+
receive
|
109
|
+
assert lock.locked?
|
110
|
+
|
111
|
+
a << Fiber.current
|
112
|
+
|
113
|
+
receive
|
114
|
+
assert !lock.locked?
|
115
|
+
end
|
73
116
|
end
|
data/test/test_thread.rb
CHANGED
@@ -124,6 +124,10 @@ class ThreadTest < MiniTest::Test
|
|
124
124
|
t&.join
|
125
125
|
end
|
126
126
|
|
127
|
+
def test_backend_class_method
|
128
|
+
assert_equal Thread.current.backend, Thread.backend
|
129
|
+
end
|
130
|
+
|
127
131
|
def test_that_suspend_returns_immediately_if_no_watchers
|
128
132
|
records = []
|
129
133
|
t = Polyphony::Trace.new(:fiber_all) do |r|
|
data/test/test_thread_pool.rb
CHANGED
data/test/test_timer.rb
CHANGED
@@ -31,7 +31,7 @@ class TimerMoveOnAfterTest < MiniTest::Test
|
|
31
31
|
end
|
32
32
|
t1 = Time.now
|
33
33
|
|
34
|
-
assert_in_range 0.01..0.
|
34
|
+
assert_in_range 0.01..0.05, t1 - t0
|
35
35
|
assert_equal :bar, v
|
36
36
|
end
|
37
37
|
|
@@ -75,14 +75,21 @@ class TimerCancelAfterTest < MiniTest::Test
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def test_timer_cancel_after_with_reset
|
78
|
-
|
78
|
+
buf = []
|
79
79
|
@timer.cancel_after(0.01) do
|
80
|
-
sleep 0.
|
80
|
+
sleep 0.005
|
81
|
+
buf << 1
|
81
82
|
@timer.reset
|
82
|
-
sleep 0.
|
83
|
+
sleep 0.005
|
84
|
+
buf << 2
|
85
|
+
@timer.reset
|
86
|
+
sleep 0.005
|
87
|
+
buf << 3
|
88
|
+
@timer.reset
|
89
|
+
sleep 0.005
|
90
|
+
buf << 4
|
83
91
|
end
|
84
|
-
|
85
|
-
assert_in_range 0.012..0.024, t1 - t0
|
92
|
+
assert_equal [1, 2, 3, 4], buf
|
86
93
|
end
|
87
94
|
|
88
95
|
class CustomException < Exception
|
@@ -140,7 +147,6 @@ class TimerMiscTest < MiniTest::Test
|
|
140
147
|
snooze
|
141
148
|
assert_equal [], buffer
|
142
149
|
sleep 0.1
|
143
|
-
p :post_sleep
|
144
150
|
assert_equal [2], buffer
|
145
151
|
end
|
146
152
|
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyphony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.55.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2021-
|
11
|
+
date: 2021-06-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -226,6 +226,20 @@ dependencies:
|
|
226
226
|
- - '='
|
227
227
|
- !ruby/object:Gem::Version
|
228
228
|
version: 0.17.1
|
229
|
+
- !ruby/object:Gem::Dependency
|
230
|
+
name: localhost
|
231
|
+
requirement: !ruby/object:Gem::Requirement
|
232
|
+
requirements:
|
233
|
+
- - "~>"
|
234
|
+
- !ruby/object:Gem::Version
|
235
|
+
version: 1.1.4
|
236
|
+
type: :development
|
237
|
+
prerelease: false
|
238
|
+
version_requirements: !ruby/object:Gem::Requirement
|
239
|
+
requirements:
|
240
|
+
- - "~>"
|
241
|
+
- !ruby/object:Gem::Version
|
242
|
+
version: 1.1.4
|
229
243
|
description:
|
230
244
|
email: sharon@noteflakes.com
|
231
245
|
executables: []
|
@@ -313,6 +327,7 @@ files:
|
|
313
327
|
- examples/core/interrupt.rb
|
314
328
|
- examples/core/nested.rb
|
315
329
|
- examples/core/pingpong.rb
|
330
|
+
- examples/core/queue.rb
|
316
331
|
- examples/core/recurrent-timer.rb
|
317
332
|
- examples/core/resource_delegate.rb
|
318
333
|
- examples/core/spin.rb
|
@@ -336,6 +351,7 @@ files:
|
|
336
351
|
- examples/io/echo_stdin.rb
|
337
352
|
- examples/io/happy-eyeballs.rb
|
338
353
|
- examples/io/httparty.rb
|
354
|
+
- examples/io/https_server.rb
|
339
355
|
- examples/io/irb.rb
|
340
356
|
- examples/io/net-http.rb
|
341
357
|
- examples/io/open.rb
|
@@ -343,6 +359,7 @@ files:
|
|
343
359
|
- examples/io/rack_server.rb
|
344
360
|
- examples/io/raw.rb
|
345
361
|
- examples/io/reline.rb
|
362
|
+
- examples/io/stdio.rb
|
346
363
|
- examples/io/system.rb
|
347
364
|
- examples/io/tcp_proxy.rb
|
348
365
|
- examples/io/tcpserver.rb
|
@@ -418,6 +435,7 @@ files:
|
|
418
435
|
- ext/polyphony/runqueue.c
|
419
436
|
- ext/polyphony/runqueue_ring_buffer.c
|
420
437
|
- ext/polyphony/runqueue_ring_buffer.h
|
438
|
+
- ext/polyphony/socket_extensions.c
|
421
439
|
- ext/polyphony/thread.c
|
422
440
|
- ext/polyphony/tracing.c
|
423
441
|
- lib/polyphony.rb
|