polyphony 0.64 → 0.68
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/workflows/test.yml +1 -1
- data/CHANGELOG.md +22 -0
- data/Gemfile.lock +1 -1
- data/TODO.md +10 -40
- data/bin/pdbg +112 -0
- data/examples/core/await.rb +9 -1
- data/ext/polyphony/backend_common.c +14 -1
- data/ext/polyphony/backend_common.h +3 -1
- data/ext/polyphony/backend_io_uring.c +85 -25
- data/ext/polyphony/backend_io_uring_context.c +42 -0
- data/ext/polyphony/backend_io_uring_context.h +6 -9
- data/ext/polyphony/backend_libev.c +85 -39
- data/ext/polyphony/fiber.c +20 -0
- data/ext/polyphony/polyphony.c +2 -0
- data/ext/polyphony/polyphony.h +5 -2
- data/ext/polyphony/queue.c +1 -1
- data/ext/polyphony/runqueue.c +7 -3
- data/ext/polyphony/runqueue.h +4 -3
- data/ext/polyphony/runqueue_ring_buffer.c +25 -14
- data/ext/polyphony/runqueue_ring_buffer.h +2 -0
- data/ext/polyphony/thread.c +2 -8
- data/lib/polyphony.rb +6 -0
- data/lib/polyphony/debugger.rb +225 -0
- data/lib/polyphony/extensions/debug.rb +1 -1
- data/lib/polyphony/extensions/fiber.rb +64 -71
- data/lib/polyphony/extensions/io.rb +4 -2
- data/lib/polyphony/extensions/openssl.rb +66 -0
- data/lib/polyphony/extensions/socket.rb +8 -2
- data/lib/polyphony/net.rb +1 -0
- data/lib/polyphony/version.rb +1 -1
- data/test/helper.rb +6 -5
- data/test/stress.rb +6 -2
- data/test/test_backend.rb +13 -4
- data/test/test_fiber.rb +35 -11
- data/test/test_global_api.rb +9 -4
- data/test/test_io.rb +2 -0
- data/test/test_socket.rb +14 -11
- data/test/test_supervise.rb +24 -24
- data/test/test_thread.rb +3 -0
- data/test/test_thread_pool.rb +1 -1
- data/test/test_throttler.rb +2 -2
- data/test/test_timer.rb +5 -3
- metadata +5 -3
data/test/test_socket.rb
CHANGED
@@ -158,19 +158,22 @@ class SocketTest < MiniTest::Test
|
|
158
158
|
end
|
159
159
|
end
|
160
160
|
|
161
|
-
|
162
|
-
|
161
|
+
if IS_LINUX
|
162
|
+
class HTTPClientTest < MiniTest::Test
|
163
163
|
|
164
|
-
|
165
|
-
res = HTTParty.get('http://ipinfo.io/')
|
164
|
+
require 'json'
|
166
165
|
|
167
|
-
|
168
|
-
|
169
|
-
|
166
|
+
def test_http
|
167
|
+
res = HTTParty.get('http://ipinfo.io/')
|
168
|
+
|
169
|
+
response = JSON.load(res.body)
|
170
|
+
assert_equal 'https://ipinfo.io/missingauth', response['readme']
|
171
|
+
end
|
170
172
|
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
173
|
+
def test_https
|
174
|
+
res = HTTParty.get('https://ipinfo.io/')
|
175
|
+
response = JSON.load(res.body)
|
176
|
+
assert_equal 'https://ipinfo.io/missingauth', response['readme']
|
177
|
+
end
|
175
178
|
end
|
176
179
|
end
|
data/test/test_supervise.rb
CHANGED
@@ -2,29 +2,29 @@
|
|
2
2
|
|
3
3
|
require_relative 'helper'
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
5
|
+
class SuperviseTest < MiniTest::Test
|
6
|
+
def test_supervise_with_no_arguments
|
7
|
+
assert_raises(RuntimeError) do
|
8
|
+
supervise
|
9
|
+
end
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_supervise_with_block
|
13
|
+
buffer = []
|
14
|
+
f1 = spin(:f1) { receive }
|
15
|
+
f2 = spin(:f2) { receive }
|
16
|
+
supervisor = spin(:supervisor) { supervise(f1, f2) { |*args| buffer << args } }
|
17
|
+
|
18
|
+
snooze
|
19
|
+
f1 << 'foo'
|
20
|
+
f1.await
|
21
|
+
10.times { snooze }
|
22
|
+
assert_equal [[f1, 'foo']], buffer
|
23
|
+
|
24
|
+
f2 << 'bar'
|
25
|
+
f2.await
|
26
|
+
assert_equal [[f1, 'foo'], [f2, 'bar']], buffer
|
27
|
+
end
|
28
28
|
|
29
29
|
# def test_supervise_with_restart
|
30
30
|
# watcher = spin { receive }
|
@@ -101,4 +101,4 @@ require_relative 'helper'
|
|
101
101
|
# assert :dead, f.state
|
102
102
|
# assert :dead, p.state
|
103
103
|
# end
|
104
|
-
|
104
|
+
end
|
data/test/test_thread.rb
CHANGED
@@ -180,6 +180,9 @@ class ThreadTest < MiniTest::Test
|
|
180
180
|
assert_equal count, GC.count
|
181
181
|
sleep 0.05
|
182
182
|
assert_equal count, GC.count
|
183
|
+
|
184
|
+
return unless IS_LINUX
|
185
|
+
|
183
186
|
# The idle tasks are ran at most once per fiber switch, before the backend
|
184
187
|
# is polled. Therefore, the second sleep will not have triggered a GC, since
|
185
188
|
# only 0.05s have passed since the gc period was set.
|
data/test/test_thread_pool.rb
CHANGED
data/test/test_throttler.rb
CHANGED
@@ -10,7 +10,7 @@ class ThrottlerTest < MiniTest::Test
|
|
10
10
|
f = spin { loop { t.process { buffer << 1 } } }
|
11
11
|
sleep 0.2
|
12
12
|
f.stop
|
13
|
-
assert_in_range 1..
|
13
|
+
assert_in_range 1..4, buffer.size
|
14
14
|
ensure
|
15
15
|
t.stop
|
16
16
|
end
|
@@ -23,7 +23,7 @@ class ThrottlerTest < MiniTest::Test
|
|
23
23
|
end
|
24
24
|
sleep 0.25
|
25
25
|
f.stop
|
26
|
-
assert_in_range 2..
|
26
|
+
assert_in_range 2..7, buffer.size
|
27
27
|
ensure
|
28
28
|
t.stop
|
29
29
|
end
|
data/test/test_timer.rb
CHANGED
@@ -19,7 +19,7 @@ class TimerMoveOnAfterTest < MiniTest::Test
|
|
19
19
|
end
|
20
20
|
t1 = Time.now
|
21
21
|
|
22
|
-
assert_in_range 0.1..0.15, t1 - t0
|
22
|
+
assert_in_range 0.1..0.15, t1 - t0 if IS_LINUX
|
23
23
|
assert_nil v
|
24
24
|
end
|
25
25
|
|
@@ -31,11 +31,13 @@ class TimerMoveOnAfterTest < MiniTest::Test
|
|
31
31
|
end
|
32
32
|
t1 = Time.now
|
33
33
|
|
34
|
-
assert_in_range 0.01..0.05, t1 - t0
|
34
|
+
assert_in_range 0.01..0.05, t1 - t0 if IS_LINUX
|
35
35
|
assert_equal :bar, v
|
36
36
|
end
|
37
37
|
|
38
38
|
def test_timer_move_on_after_with_reset
|
39
|
+
skip unless IS_LINUX
|
40
|
+
|
39
41
|
t0 = Time.now
|
40
42
|
v = @timer.move_on_after(0.01, with_value: :moved_on) do
|
41
43
|
sleep 0.007
|
@@ -71,7 +73,7 @@ class TimerCancelAfterTest < MiniTest::Test
|
|
71
73
|
end
|
72
74
|
end
|
73
75
|
t1 = Time.now
|
74
|
-
assert_in_range 0.01..0.03, t1 - t0
|
76
|
+
assert_in_range 0.01..0.03, t1 - t0 if IS_LINUX
|
75
77
|
end
|
76
78
|
|
77
79
|
def test_timer_cancel_after_with_reset
|
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.68'
|
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-08-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -156,6 +156,7 @@ files:
|
|
156
156
|
- README.md
|
157
157
|
- Rakefile
|
158
158
|
- TODO.md
|
159
|
+
- bin/pdbg
|
159
160
|
- bin/polyphony-debug
|
160
161
|
- bin/stress.rb
|
161
162
|
- bin/test
|
@@ -356,6 +357,7 @@ files:
|
|
356
357
|
- lib/polyphony/core/thread_pool.rb
|
357
358
|
- lib/polyphony/core/throttler.rb
|
358
359
|
- lib/polyphony/core/timer.rb
|
360
|
+
- lib/polyphony/debugger.rb
|
359
361
|
- lib/polyphony/extensions/core.rb
|
360
362
|
- lib/polyphony/extensions/debug.rb
|
361
363
|
- lib/polyphony/extensions/fiber.rb
|
@@ -419,7 +421,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
419
421
|
- !ruby/object:Gem::Version
|
420
422
|
version: '0'
|
421
423
|
requirements: []
|
422
|
-
rubygems_version: 3.1.
|
424
|
+
rubygems_version: 3.1.4
|
423
425
|
signing_key:
|
424
426
|
specification_version: 4
|
425
427
|
summary: Fine grained concurrency for Ruby
|