polyphony 0.34 → 0.36

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.
@@ -13,7 +13,7 @@ if Object.constants.include?(:Reline)
13
13
  fiber = Fiber.current
14
14
  timer = spin do
15
15
  sleep timeout
16
- fiber.cancel!
16
+ fiber.cancel
17
17
  end
18
18
  read_ios.each do |io|
19
19
  io.read_watcher.await
@@ -22,7 +22,7 @@ class ThreadPool
22
22
  def process(&block)
23
23
  setup unless @task_queue
24
24
 
25
- async = Gyro::Async.new
25
+ async = Fiber.current.auto_async
26
26
  @task_queue << [block, async]
27
27
  async.await
28
28
  end
@@ -45,8 +45,8 @@ class ThreadPool
45
45
  def run_queued_task
46
46
  (block, watcher) = @task_queue.pop
47
47
  result = block.()
48
- watcher&.signal!(result)
48
+ watcher&.signal(result)
49
49
  rescue Exception => e
50
- watcher ? watcher.signal!(e) : raise(e)
50
+ watcher ? watcher.signal(e) : raise(e)
51
51
  end
52
52
  end
@@ -41,7 +41,7 @@ module FiberControl
41
41
  end
42
42
  alias_method :reset, :restart
43
43
 
44
- def cancel!
44
+ def cancel
45
45
  return if @running == false
46
46
 
47
47
  schedule Exceptions::Cancel.new
@@ -48,12 +48,12 @@ class ::Thread
48
48
  end
49
49
 
50
50
  def signal_waiters(result)
51
- @join_wait_queue.shift_each { |w| w.signal!(result) }
51
+ @join_wait_queue.shift_each { |w| w.signal(result) }
52
52
  end
53
53
 
54
54
  alias_method :orig_join, :join
55
55
  def join(timeout = nil)
56
- async = Gyro::Async.new
56
+ async = Fiber.current.auto_async
57
57
  @finalization_mutex.synchronize do
58
58
  if @terminated
59
59
  @result.is_a?(Exception) ? (raise @result) : (return @result)
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  module Polyphony
4
- VERSION = '0.34'
4
+ VERSION = '0.36'
5
5
  end
data/test/test_async.rb CHANGED
@@ -13,7 +13,7 @@ class AsyncTest < MiniTest::Test
13
13
  snooze
14
14
  Thread.new do
15
15
  orig_sleep 0.001
16
- a.signal!
16
+ a.signal
17
17
  end
18
18
  suspend
19
19
  assert_equal 1, count
@@ -32,7 +32,7 @@ class AsyncTest < MiniTest::Test
32
32
  snooze
33
33
  Thread.new do
34
34
  orig_sleep 0.001
35
- 3.times { a.signal! }
35
+ 3.times { a.signal }
36
36
  end
37
37
  coproc.await
38
38
  assert_equal 1, count
data/test/test_fiber.rb CHANGED
@@ -113,7 +113,7 @@ class FiberTest < MiniTest::Test
113
113
  async = Gyro::Async.new
114
114
  worker = Thread.new do
115
115
  worker_fiber = Fiber.current
116
- async.signal!
116
+ async.signal
117
117
  suspend
118
118
  buffer << :foo
119
119
  end
@@ -132,7 +132,7 @@ class FiberTest < MiniTest::Test
132
132
  t = Thread.new do
133
133
  f = spin_loop { snooze }
134
134
  sleep 0.001
135
- async.signal!(:foo)
135
+ async.signal(:foo)
136
136
  end
137
137
 
138
138
  result = move_on_after(1) { async.await }
@@ -299,7 +299,7 @@ class FiberTest < MiniTest::Test
299
299
  2.times { snooze }
300
300
  result << 2
301
301
  end
302
- spin { f.cancel! }
302
+ spin { f.cancel }
303
303
  assert_equal 0, result.size
304
304
  begin
305
305
  f.await
@@ -645,7 +645,7 @@ class FiberTest < MiniTest::Test
645
645
  o.close
646
646
  end
647
647
  end
648
- sleep 0.1
648
+ sleep 0.2
649
649
  f = spin { Gyro::Child.new(pid).await }
650
650
  o.close
651
651
  Process.kill('TERM', pid)
@@ -106,7 +106,7 @@ class MoveOnAfterTest < MiniTest::Test
106
106
  end
107
107
  t1 = Time.now
108
108
 
109
- assert t1 - t0 < 0.02
109
+ assert t1 - t0 < 0.03
110
110
  assert_nil v
111
111
  end
112
112
 
@@ -68,7 +68,7 @@ class ThreadPoolTest < MiniTest::Test
68
68
  assert elapsed < 0.007
69
69
  assert buffer.size < 2
70
70
 
71
- sleep 0.08 # allow time for threads to spawn
71
+ sleep 0.1 # allow time for threads to spawn
72
72
  assert_equal @pool.size, threads.uniq.size
73
73
  assert_equal (0..9).to_a, buffer.sort
74
74
  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: '0.34'
4
+ version: '0.36'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2020-03-25 00:00:00.000000000 Z
11
+ date: 2020-03-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: modulation
@@ -264,6 +264,11 @@ files:
264
264
  - docs/api-reference.md
265
265
  - docs/api-reference/exception.md
266
266
  - docs/api-reference/fiber.md
267
+ - docs/api-reference/gyro-async.md
268
+ - docs/api-reference/gyro-child.md
269
+ - docs/api-reference/gyro-queue.md
270
+ - docs/api-reference/gyro-timer.md
271
+ - docs/api-reference/gyro.md
267
272
  - docs/api-reference/io.md
268
273
  - docs/api-reference/object.md
269
274
  - docs/api-reference/polyphony-baseexception.md
@@ -339,6 +344,7 @@ files:
339
344
  - examples/core/xx-thread_pool.rb
340
345
  - examples/core/xx-throttling.rb
341
346
  - examples/core/xx-timeout.rb
347
+ - examples/core/xx-timer-gc.rb
342
348
  - examples/core/xx-trace.rb
343
349
  - examples/core/xx-using-a-mutex.rb
344
350
  - examples/core/xx-worker-thread.rb
@@ -372,6 +378,7 @@ files:
372
378
  - ext/gyro/async.c
373
379
  - ext/gyro/child.c
374
380
  - ext/gyro/extconf.rb
381
+ - ext/gyro/fiber.c
375
382
  - ext/gyro/gyro.c
376
383
  - ext/gyro/gyro.h
377
384
  - ext/gyro/gyro_ext.c