polyphony 0.15 → 0.16

Sign up to get free protection for your applications and to get access to all the features.
Files changed (89) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +6 -0
  3. data/Gemfile.lock +11 -3
  4. data/TODO.md +25 -14
  5. data/docs/getting-started/getting-started.md +1 -1
  6. data/docs/getting-started/tutorial.md +2 -0
  7. data/examples/core/cancel.rb +2 -3
  8. data/examples/core/channel_echo.rb +2 -3
  9. data/examples/core/enumerator.rb +2 -3
  10. data/examples/core/fork.rb +2 -2
  11. data/examples/core/genserver.rb +2 -3
  12. data/examples/core/lock.rb +2 -3
  13. data/examples/core/move_on.rb +2 -3
  14. data/examples/core/move_on_twice.rb +2 -3
  15. data/examples/core/move_on_with_ensure.rb +2 -3
  16. data/examples/core/{multiple_async.rb → multiple_spawn.rb} +2 -3
  17. data/examples/core/nested_async.rb +2 -3
  18. data/examples/core/nested_cancel.rb +2 -3
  19. data/examples/core/{nested_multiple_async.rb → nested_multiple_spawn.rb} +2 -3
  20. data/examples/core/next_tick.rb +4 -5
  21. data/examples/core/pulse.rb +2 -3
  22. data/examples/core/resource.rb +2 -3
  23. data/examples/core/resource_cancel.rb +2 -3
  24. data/examples/core/resource_delegate.rb +2 -3
  25. data/examples/core/sleep.rb +2 -3
  26. data/examples/core/sleep_spawn.rb +19 -0
  27. data/examples/core/spawn.rb +2 -3
  28. data/examples/core/spawn_cancel.rb +2 -3
  29. data/examples/core/spawn_error.rb +2 -2
  30. data/examples/core/supervisor.rb +2 -3
  31. data/examples/core/supervisor_with_cancel_scope.rb +2 -3
  32. data/examples/core/supervisor_with_error.rb +2 -3
  33. data/examples/core/supervisor_with_manual_move_on.rb +2 -3
  34. data/examples/core/thread.rb +3 -6
  35. data/examples/core/thread_cancel.rb +2 -5
  36. data/examples/core/thread_pool.rb +3 -6
  37. data/examples/core/throttle.rb +2 -3
  38. data/examples/fs/read.rb +22 -19
  39. data/examples/http/happy_eyeballs.rb +2 -2
  40. data/examples/http/http_client.rb +5 -7
  41. data/examples/http/http_server.rb +2 -3
  42. data/examples/http/http_server_forked.rb +2 -3
  43. data/examples/http/http_server_throttled.rb +2 -3
  44. data/examples/http/http_ws_server.rb +4 -4
  45. data/examples/http/https_raw_client.rb +4 -5
  46. data/examples/http/https_server.rb +2 -3
  47. data/examples/http/https_wss_server.rb +2 -3
  48. data/examples/http/rack_server.rb +2 -4
  49. data/examples/http/rack_server_https.rb +2 -3
  50. data/examples/http/rack_server_https_forked.rb +2 -3
  51. data/examples/http/websocket_secure_server.rb +2 -3
  52. data/examples/http/websocket_server.rb +2 -3
  53. data/examples/interfaces/pg_client.rb +2 -4
  54. data/examples/interfaces/pg_pool.rb +4 -6
  55. data/examples/interfaces/{pg_query.rb → pg_transaction.rb} +2 -4
  56. data/examples/interfaces/redis_channels.rb +2 -4
  57. data/examples/interfaces/redis_client.rb +2 -4
  58. data/examples/interfaces/redis_pubsub.rb +2 -4
  59. data/examples/interfaces/redis_pubsub_perf.rb +2 -4
  60. data/examples/io/echo_client.rb +4 -5
  61. data/examples/io/echo_server.rb +2 -2
  62. data/examples/io/echo_server_with_timeout.rb +3 -5
  63. data/examples/io/echo_stdin.rb +3 -4
  64. data/examples/performance/perf_multi_snooze.rb +2 -2
  65. data/examples/performance/perf_snooze.rb +2 -2
  66. data/examples/performance/thread-vs-fiber/polyphony_server.rb +4 -5
  67. data/ext/ev/ev_module.c +3 -2
  68. data/lib/polyphony/{resource_pool.rb → core/resource_pool.rb} +0 -0
  69. data/lib/polyphony/core/supervisor.rb +8 -8
  70. data/lib/polyphony/extensions/{ssl.rb → openssl.rb} +0 -0
  71. data/lib/polyphony/http/agent.rb +1 -1
  72. data/lib/polyphony/http.rb +12 -4
  73. data/lib/polyphony/net.rb +8 -11
  74. data/lib/polyphony/{extensions/postgres.rb → postgres.rb} +1 -4
  75. data/lib/polyphony/{extensions/redis.rb → redis.rb} +3 -6
  76. data/lib/polyphony/version.rb +1 -1
  77. data/lib/polyphony/websocket.rb +1 -1
  78. data/lib/polyphony.rb +57 -21
  79. data/polyphony.gemspec +5 -4
  80. data/test/test_coprocess.rb +88 -15
  81. data/test/test_core.rb +142 -232
  82. data/test/test_ev.rb +88 -95
  83. data/test/test_io.rb +35 -41
  84. metadata +68 -16
  85. data/examples/core/sleep2.rb +0 -13
  86. data/examples/streams/lines.rb +0 -27
  87. data/examples/streams/stdio.rb +0 -18
  88. data/lib/polyphony/core.rb +0 -45
  89. data/lib/polyphony/server_task.rb +0 -18
data/test/test_ev.rb CHANGED
@@ -1,117 +1,110 @@
1
1
  require 'minitest/autorun'
2
- require 'modulation'
2
+ require 'bundler/setup'
3
+ require 'polyphony'
3
4
 
4
- module EVTest
5
- Core = import('../lib/polyphony/core')
5
+ class EVRunTest < Minitest::Test
6
+ def setup
7
+ EV.rerun
8
+ end
6
9
 
7
- class RunTest < Minitest::Test
8
- def setup
9
- EV.break
10
- EV.restart
11
- end
10
+ def test_that_run_loop_returns_immediately_if_no_watchers
11
+ t0 = Time.now
12
+ suspend
13
+ t1 = Time.now
14
+ assert (t1 - t0) < 0.001
15
+ end
16
+ end
12
17
 
13
- def test_that_run_loop_returns_immediately_if_no_watchers
14
- t0 = Time.now
15
- suspend
16
- t1 = Time.now
17
- assert (t1 - t0) < 0.001
18
- end
18
+ class EVTimerTest < MiniTest::Test
19
+ def setup
20
+ EV.rerun
19
21
  end
20
22
 
21
- class TimerTest < MiniTest::Test
22
- def setup
23
- EV.break
24
- EV.restart
25
- end
23
+ def test_that_one_shot_timer_works
24
+ count = 0
25
+ t = EV::Timer.new(0.01, 0)
26
+ t.start { count += 1}
27
+ suspend
28
+ assert_equal(1, count)
29
+ end
26
30
 
27
- def test_that_one_shot_timer_works
28
- count = 0
29
- t = EV::Timer.new(0.01, 0)
30
- t.start { count += 1}
31
- suspend
32
- assert_equal(1, count)
33
- end
31
+ def test_that_repeating_timer_works
32
+ count = 0
33
+ t = EV::Timer.new(0.001, 0.001)
34
+ t.start { count += 1; t.stop if count >= 3}
35
+ suspend
36
+ assert_equal(3, count)
37
+ end
38
+ end
34
39
 
35
- def test_that_repeating_timer_works
36
- count = 0
37
- t = EV::Timer.new(0.001, 0.001)
38
- t.start { count += 1; t.stop if count >= 3}
39
- suspend
40
- assert_equal(3, count)
41
- end
40
+ class EVIOTest < MiniTest::Test
41
+ def setup
42
+ EV.rerun
42
43
  end
43
-
44
- class IOTest < MiniTest::Test
45
- def setup
46
- EV.break
47
- EV.restart
48
- end
49
44
 
50
- def test_that_reading_works
51
- i, o = IO.pipe
52
- data = +''
53
- w = EV::IO.new(i, :r)
54
- w.start do
55
- i.read_nonblock(8192, data)
56
- w.stop unless data.empty?
57
- end
58
- EV::Timer.new(0, 0).start { o << 'hello' }
59
- suspend
60
- assert_equal('hello', data)
45
+ def test_that_reading_works
46
+ i, o = IO.pipe
47
+ data = +''
48
+ w = EV::IO.new(i, :r)
49
+ w.start do
50
+ i.read_nonblock(8192, data)
51
+ w.stop unless data.empty?
61
52
  end
53
+ EV::Timer.new(0, 0).start { o << 'hello' }
54
+ suspend
55
+ assert_equal('hello', data)
62
56
  end
57
+ end
63
58
 
64
- class SignalTest < MiniTest::Test
65
- def setup
66
- EV.break
67
- EV.restart
68
- end
59
+ class EVSignalTest < MiniTest::Test
60
+ def setup
61
+ EV.rerun
62
+ EV.restart
63
+ end
69
64
 
70
- def test_that_signal_watcher_receives_signal
71
- sig = Signal.list['USR1']
72
- count = 0
73
- w = EV::Signal.new(sig) { count += 1; w.stop }
74
- Thread.new { sync_sleep 0.001; Process.kill(:USR1, Process.pid) }
75
- suspend
76
- assert_equal(1, count)
77
- end
65
+ def test_that_signal_watcher_receives_signal
66
+ sig = Signal.list['USR1']
67
+ count = 0
68
+ w = EV::Signal.new(sig) { count += 1; w.stop }
69
+ Thread.new { sync_sleep 0.001; Process.kill(:USR1, Process.pid) }
70
+ suspend
71
+ assert_equal(1, count)
72
+ end
78
73
 
79
- def test_that_signal_watcher_receives_signal
80
- count = 0
81
- w = Core.trap(:usr1, true) { count += 1; w.stop }
82
- assert_kind_of(EV::Signal, w)
83
- Thread.new { sync_sleep 0.001; Process.kill(:USR1, Process.pid) }
84
- suspend
85
- assert_equal(1, count)
86
- end
74
+ def test_that_signal_watcher_receives_signal
75
+ count = 0
76
+ w = Polyphony.trap(:usr1, true) { count += 1; w.stop }
77
+ assert_kind_of(EV::Signal, w)
78
+ Thread.new { sync_sleep 0.001; Process.kill(:USR1, Process.pid) }
79
+ suspend
80
+ assert_equal(1, count)
87
81
  end
82
+ end
88
83
 
89
- class AsyncTest < MiniTest::Test
90
- def setup
91
- EV.break
92
- EV.restart
93
- end
84
+ class EVAsyncTest < MiniTest::Test
85
+ def setup
86
+ EV.rerun
87
+ end
94
88
 
95
- def test_that_async_watcher_receives_signal_across_threads
96
- count = 0
97
- a = EV::Async.new { count += 1; a.stop }
98
- Thread.new { sync_sleep 0.001; a.signal! }
99
- suspend
100
- assert_equal(1, count)
101
- end
89
+ def test_that_async_watcher_receives_signal_across_threads
90
+ count = 0
91
+ a = EV::Async.new { count += 1; a.stop }
92
+ Thread.new { sync_sleep 0.001; a.signal! }
93
+ suspend
94
+ assert_equal(1, count)
95
+ end
102
96
 
103
- def test_that_async_watcher_coalesces_signals
104
- count = 0
105
- a = EV::Async.new do
106
- count += 1
107
- EV::Timer.new(0.01, 0).start { a.stop }
108
- end
109
- Thread.new do
110
- sync_sleep 0.001
111
- 3.times { a.signal! }
112
- end
113
- suspend
114
- assert_equal(1, count)
97
+ def test_that_async_watcher_coalesces_signals
98
+ count = 0
99
+ a = EV::Async.new do
100
+ count += 1
101
+ EV::Timer.new(0.01, 0).start { a.stop }
102
+ end
103
+ Thread.new do
104
+ sync_sleep 0.001
105
+ 3.times { a.signal! }
115
106
  end
107
+ suspend
108
+ assert_equal(1, count)
116
109
  end
117
110
  end
data/test/test_io.rb CHANGED
@@ -1,48 +1,42 @@
1
1
  require 'minitest/autorun'
2
- require 'modulation'
2
+ require 'bundler/setup'
3
+ require 'polyphony'
3
4
 
4
- module IOTests
5
- Core = import('../lib/polyphony/core')
6
- import('../lib/polyphony/extensions/io')
7
-
8
- class IOTest < MiniTest::Test
9
- def setup
10
- EV.rerun
11
- @i, @o = IO.pipe
12
- end
13
-
14
- def test_that_io_op_yields_to_other_fibers
15
- count = 0
16
- msg = nil
17
- [
18
- spawn {
19
- @o.write("hello")
20
- @o.close
21
- },
22
-
23
- spawn {
24
- while count < 5
25
- sleep 0.01
26
- count += 1
27
- end
28
- },
29
-
30
- spawn {
31
- msg = @i.read
32
- }
33
- ].each(&:await)
34
- assert_equal(5, count)
35
- assert_equal("hello", msg)
36
- end
5
+ class IOTest < MiniTest::Test
6
+ def setup
7
+ EV.rerun
8
+ @i, @o = IO.pipe
9
+ end
37
10
 
38
- def test_that_double_chevron_method_returns_io
39
- assert_equal(@o, @o << 'foo')
11
+ def test_that_io_op_yields_to_other_fibers
12
+ count = 0
13
+ msg = nil
14
+ [
15
+ spawn {
16
+ @o.write("hello")
17
+ @o.close
18
+ },
19
+
20
+ spawn {
21
+ while count < 5
22
+ sleep 0.01
23
+ count += 1
24
+ end
25
+ },
26
+
27
+ spawn {
28
+ msg = @i.read
29
+ }
30
+ ].each(&:await)
31
+ assert_equal(5, count)
32
+ assert_equal("hello", msg)
33
+ end
40
34
 
41
- @o << 'bar' << 'baz'
42
- @o.close
43
- assert_equal('foobarbaz', @i.read)
44
- end
35
+ def test_that_double_chevron_method_returns_io
36
+ assert_equal(@o, @o << 'foo')
45
37
 
46
- def test_
38
+ @o << 'bar' << 'baz'
39
+ @o.close
40
+ assert_equal('foobarbaz', @i.read)
47
41
  end
48
42
  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.15'
4
+ version: '0.16'
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2019-05-20 00:00:00.000000000 Z
11
+ date: 2019-05-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: modulation
@@ -16,14 +16,14 @@ dependencies:
16
16
  requirements:
17
17
  - - '='
18
18
  - !ruby/object:Gem::Version
19
- version: '0.23'
19
+ version: '0.24'
20
20
  type: :runtime
21
21
  prerelease: false
22
22
  version_requirements: !ruby/object:Gem::Requirement
23
23
  requirements:
24
24
  - - '='
25
25
  - !ruby/object:Gem::Version
26
- version: '0.23'
26
+ version: '0.24'
27
27
  - !ruby/object:Gem::Dependency
28
28
  name: http_parser.rb
29
29
  requirement: !ruby/object:Gem::Requirement
@@ -94,6 +94,62 @@ dependencies:
94
94
  - - '='
95
95
  - !ruby/object:Gem::Version
96
96
  version: 1.1.4
97
+ - !ruby/object:Gem::Dependency
98
+ name: websocket
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - '='
102
+ - !ruby/object:Gem::Version
103
+ version: 1.2.8
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - '='
109
+ - !ruby/object:Gem::Version
110
+ version: 1.2.8
111
+ - !ruby/object:Gem::Dependency
112
+ name: pg
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - '='
116
+ - !ruby/object:Gem::Version
117
+ version: 1.1.3
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - '='
123
+ - !ruby/object:Gem::Version
124
+ version: 1.1.3
125
+ - !ruby/object:Gem::Dependency
126
+ name: redis
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - '='
130
+ - !ruby/object:Gem::Version
131
+ version: 4.1.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - '='
137
+ - !ruby/object:Gem::Version
138
+ version: 4.1.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: hiredis
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - '='
144
+ - !ruby/object:Gem::Version
145
+ version: 0.6.3
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - '='
151
+ - !ruby/object:Gem::Version
152
+ version: 0.6.3
97
153
  description:
98
154
  email: ciconia@gmail.com
99
155
  executables: []
@@ -125,17 +181,17 @@ files:
125
181
  - examples/core/move_on.rb
126
182
  - examples/core/move_on_twice.rb
127
183
  - examples/core/move_on_with_ensure.rb
128
- - examples/core/multiple_async.rb
184
+ - examples/core/multiple_spawn.rb
129
185
  - examples/core/nested_async.rb
130
186
  - examples/core/nested_cancel.rb
131
- - examples/core/nested_multiple_async.rb
187
+ - examples/core/nested_multiple_spawn.rb
132
188
  - examples/core/next_tick.rb
133
189
  - examples/core/pulse.rb
134
190
  - examples/core/resource.rb
135
191
  - examples/core/resource_cancel.rb
136
192
  - examples/core/resource_delegate.rb
137
193
  - examples/core/sleep.rb
138
- - examples/core/sleep2.rb
194
+ - examples/core/sleep_spawn.rb
139
195
  - examples/core/spawn.rb
140
196
  - examples/core/spawn_cancel.rb
141
197
  - examples/core/spawn_error.rb
@@ -168,7 +224,7 @@ files:
168
224
  - examples/http/wss_page.html
169
225
  - examples/interfaces/pg_client.rb
170
226
  - examples/interfaces/pg_pool.rb
171
- - examples/interfaces/pg_query.rb
227
+ - examples/interfaces/pg_transaction.rb
172
228
  - examples/interfaces/redis_channels.rb
173
229
  - examples/interfaces/redis_client.rb
174
230
  - examples/interfaces/redis_pubsub.rb
@@ -181,8 +237,6 @@ files:
181
237
  - examples/performance/perf_snooze.rb
182
238
  - examples/performance/thread-vs-fiber/polyphony_server.rb
183
239
  - examples/performance/thread-vs-fiber/threaded_server.rb
184
- - examples/streams/lines.rb
185
- - examples/streams/stdio.rb
186
240
  - ext/ev/async.c
187
241
  - ext/ev/child.c
188
242
  - ext/ev/ev.h
@@ -209,12 +263,12 @@ files:
209
263
  - ext/libev/ev_wrap.h
210
264
  - ext/libev/test_libev_win32.c
211
265
  - lib/polyphony.rb
212
- - lib/polyphony/core.rb
213
266
  - lib/polyphony/core/cancel_scope.rb
214
267
  - lib/polyphony/core/channel.rb
215
268
  - lib/polyphony/core/coprocess.rb
216
269
  - lib/polyphony/core/exceptions.rb
217
270
  - lib/polyphony/core/fiber_pool.rb
271
+ - lib/polyphony/core/resource_pool.rb
218
272
  - lib/polyphony/core/supervisor.rb
219
273
  - lib/polyphony/core/sync.rb
220
274
  - lib/polyphony/core/thread.rb
@@ -222,10 +276,8 @@ files:
222
276
  - lib/polyphony/core/throttler.rb
223
277
  - lib/polyphony/extensions/io.rb
224
278
  - lib/polyphony/extensions/kernel.rb
225
- - lib/polyphony/extensions/postgres.rb
226
- - lib/polyphony/extensions/redis.rb
279
+ - lib/polyphony/extensions/openssl.rb
227
280
  - lib/polyphony/extensions/socket.rb
228
- - lib/polyphony/extensions/ssl.rb
229
281
  - lib/polyphony/fs.rb
230
282
  - lib/polyphony/http.rb
231
283
  - lib/polyphony/http/agent.rb
@@ -237,8 +289,8 @@ files:
237
289
  - lib/polyphony/http/server.rb
238
290
  - lib/polyphony/line_reader.rb
239
291
  - lib/polyphony/net.rb
240
- - lib/polyphony/resource_pool.rb
241
- - lib/polyphony/server_task.rb
292
+ - lib/polyphony/postgres.rb
293
+ - lib/polyphony/redis.rb
242
294
  - lib/polyphony/version.rb
243
295
  - lib/polyphony/websocket.rb
244
296
  - polyphony.gemspec
@@ -1,13 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
6
-
7
- spawn {
8
- puts "going to sleep..."
9
- sleep 1
10
- puts "woke up"
11
- }.await
12
-
13
- puts "done"
@@ -1,27 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
6
- LineReader = import('../../lib/polyphony/line_reader')
7
-
8
- buffer = +''
9
- reader = LineReader.new
10
-
11
- Polyphony.interval(0.2) { buffer << "#{Time.now.to_f}\n" }
12
- Polyphony.interval(0.3) do
13
-
14
- reader.push(buffer.slice!(0, buffer.bytesize / 10 * 10))
15
- end
16
-
17
- Polyphony.async do
18
- reader.lines.each do |line|
19
- puts "* #{line}"
20
- end
21
- puts "no more lines"
22
- end
23
-
24
- Polyphony.timeout(2) do
25
- Polyphony.cancel_all_timers
26
- reader.close
27
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- require 'modulation'
4
-
5
- Polyphony = import('../../lib/polyphony')
6
-
7
- input = Polyphony::IO.lines(Polyphony::IO.stdin)
8
-
9
- Polyphony.async do
10
- Polyphony.interval(1) { puts Time.now }
11
-
12
- loop do
13
- Polyphony::IO.stdout << "Say something: "
14
- l = Polyphony.await(input)
15
- break unless l
16
- Polyphony::IO.stdout << "You said: #{l}"
17
- end
18
- end
@@ -1,45 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- export_default :Core
4
-
5
- require 'fiber'
6
- require_relative '../ev_ext'
7
-
8
- import('./extensions/kernel')
9
- FiberPool = import('./core/fiber_pool')
10
-
11
- # Core module, containing async and reactor methods
12
- module Core
13
- def self.trap(sig, ref = false, &callback)
14
- sig = Signal.list[sig.to_s.upcase] if sig.is_a?(Symbol)
15
- watcher = EV::Signal.new(sig, &callback)
16
- EV.unref unless ref
17
- watcher
18
- end
19
-
20
- def self.fork(&block)
21
- EV.break
22
- pid = Kernel.fork do
23
- FiberPool.reset!
24
- EV.post_fork
25
- Fiber.current.coprocess = Coprocess.new(Fiber.current)
26
-
27
- block.()
28
-
29
- # We cannot simply depend on the at_exit block (see below) to yield to the
30
- # reactor fiber. Doing that will raise a FiberError complaining: "fiber
31
- # called across stack rewinding barrier". Apparently this is a bug in
32
- # Ruby, so the workaround is to yield just before exiting.
33
- suspend
34
- end
35
- EV.restart
36
- pid
37
- end
38
- end
39
-
40
- at_exit do
41
- # in most cases, by the main fiber is done there are still pending or other
42
- # or asynchronous operations going on. If the reactor loop is not done, we
43
- # suspend the root fiber until it is done
44
- suspend if $__reactor_fiber__&.alive?
45
- end
@@ -1,18 +0,0 @@
1
- # frozen_string_literal: true
2
-
3
- export_default :ServerTask
4
-
5
- Channel = import('./core/channel')
6
- Task = import('./core/task')
7
-
8
- class ServerTask
9
- def initialize
10
- super {
11
- loop {
12
- message = await @mailbox.receive
13
- handle(message)
14
- }
15
- }
16
- @mailbox = Channel.new
17
- end
18
- end