polyphony 1.0.2 → 1.1.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -72,4 +72,4 @@ class ProcessSupervisionTest < MiniTest::Test
72
72
  assert_equal "foo\n", IO.read(fn)
73
73
 
74
74
  end
75
- end
75
+ end
@@ -126,4 +126,4 @@ class ResourcePoolTest < MiniTest::Test
126
126
 
127
127
  assert_equal [1, 1, 1, 1], buf
128
128
  end
129
- end
129
+ end
@@ -0,0 +1,38 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helper'
4
+
5
+ class ScenarioTest < MiniTest::Test
6
+ def test_monocrono
7
+ count = 256
8
+
9
+ workers = {}
10
+ count.times do |i|
11
+ factor = i + 1
12
+ workers[i] = spin_loop do
13
+ peer, num = receive
14
+ peer << (num * factor)
15
+ end
16
+ end
17
+
18
+ router = spin_loop do
19
+ peer, id, num = receive
20
+ worker = workers[id]
21
+ worker << [peer, num]
22
+ end
23
+
24
+ results = []
25
+ (count * 256).times do
26
+ id = rand(count)
27
+ num = rand(1000)
28
+ router << [Fiber.current, id, num]
29
+ result = receive
30
+ assert_equal num * (id + 1), result
31
+ end
32
+ ensure
33
+ workers.each_value do |w|
34
+ w.kill
35
+ w.join
36
+ end
37
+ end
38
+ end
data/test/test_socket.rb CHANGED
@@ -477,5 +477,4 @@ class MultishotAcceptTest < MiniTest::Test
477
477
  server_fiber.await
478
478
  assert_kind_of Errno::EBADF, error
479
479
  end
480
-
481
480
  end
@@ -25,7 +25,9 @@ class ThreadPoolTest < MiniTest::Test
25
25
  threads = []
26
26
  results = []
27
27
 
28
- 20.times do |i|
28
+ count = 40
29
+
30
+ count.times do |i|
29
31
  spin do
30
32
  results << @pool.process do
31
33
  threads << Thread.current
@@ -38,7 +40,7 @@ class ThreadPoolTest < MiniTest::Test
38
40
  suspend
39
41
 
40
42
  assert_equal @pool.size, threads.uniq.size
41
- assert_equal (0..19).map { |i| i * 10}, results.sort
43
+ assert_equal (0..(count - 1)).map { |i| i * 10}, results.sort
42
44
  end
43
45
 
44
46
  def test_process_with_exception
data/test/test_timer.rb CHANGED
@@ -50,7 +50,7 @@ class TimerMoveOnAfterTest < MiniTest::Test
50
50
  t1 = Time.now
51
51
 
52
52
  assert_nil v
53
- assert_in_range 0.15..0.4, t1 - t0
53
+ assert_in_range 0.12..0.4, t1 - t0
54
54
  end
55
55
  end
56
56
 
@@ -162,4 +162,4 @@ class TimerMiscTest < MiniTest::Test
162
162
  f.stop
163
163
  assert_in_range 3..7, buffer.size if IS_LINUX
164
164
  end
165
- end
165
+ end
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: 1.0.2
4
+ version: 1.1.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2023-05-28 00:00:00.000000000 Z
11
+ date: 2023-06-08 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake-compiler
@@ -179,6 +179,7 @@ files:
179
179
  - docs/_user-guide/all-about-timers.md
180
180
  - docs/_user-guide/index.md
181
181
  - docs/_user-guide/web-server.md
182
+ - docs/advanced-io.md
182
183
  - docs/assets/echo-fibers.svg
183
184
  - docs/assets/polyphony-logo.png
184
185
  - docs/assets/sleeping-fiber.svg
@@ -231,12 +232,14 @@ files:
231
232
  - examples/core/shutdown_all_children.rb
232
233
  - examples/core/spin.rb
233
234
  - examples/core/spin_error_backtrace.rb
235
+ - examples/core/stream_mockup.rb
234
236
  - examples/core/supervise-process.rb
235
237
  - examples/core/supervisor.rb
236
238
  - examples/core/suspend.rb
237
239
  - examples/core/terminate_main_fiber.rb
238
240
  - examples/core/thread-sleep.rb
239
241
  - examples/core/thread_pool.rb
242
+ - examples/core/throttled_loop_inside_move_on_after.rb
240
243
  - examples/core/throttling.rb
241
244
  - examples/core/timeout.rb
242
245
  - examples/core/trap1.rb
@@ -404,6 +407,7 @@ files:
404
407
  - test/test_queue.rb
405
408
  - test/test_raw_buffer.rb
406
409
  - test/test_resource_pool.rb
410
+ - test/test_scenarios.rb
407
411
  - test/test_signal.rb
408
412
  - test/test_socket.rb
409
413
  - test/test_supervise.rb
@@ -643,7 +647,7 @@ files:
643
647
  - vendor/liburing/test/version.c
644
648
  - vendor/liburing/test/wakeup-hang.c
645
649
  - vendor/liburing/test/xattr.c
646
- homepage: https://digital-fabric.github.io/polyphony
650
+ homepage: https://github.com/digital-fabric/polyphony
647
651
  licenses:
648
652
  - MIT
649
653
  metadata: