polyphony 0.43.10 → 0.45.2

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.
Files changed (142) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +8 -1
  3. data/CHANGELOG.md +37 -0
  4. data/Gemfile.lock +16 -6
  5. data/Rakefile +1 -1
  6. data/TODO.md +15 -10
  7. data/docs/_posts/2020-07-26-polyphony-0.44.md +77 -0
  8. data/docs/api-reference/thread.md +1 -1
  9. data/docs/getting-started/overview.md +14 -14
  10. data/docs/getting-started/tutorial.md +1 -1
  11. data/examples/adapters/redis_client.rb +3 -1
  12. data/examples/adapters/redis_pubsub_perf.rb +11 -8
  13. data/examples/adapters/sequel_mysql.rb +23 -0
  14. data/examples/adapters/sequel_mysql_pool.rb +33 -0
  15. data/examples/adapters/sequel_pg.rb +24 -0
  16. data/examples/core/{02-awaiting-fibers.rb → await.rb} +0 -0
  17. data/examples/core/{xx-channels.rb → channels.rb} +0 -0
  18. data/examples/core/deferring-an-operation.rb +16 -0
  19. data/examples/core/{xx-erlang-style-genserver.rb → erlang-style-genserver.rb} +16 -9
  20. data/examples/core/{xx-forking.rb → forking.rb} +1 -1
  21. data/examples/core/handling-signals.rb +11 -0
  22. data/examples/core/{03-interrupting.rb → interrupt.rb} +0 -0
  23. data/examples/core/{xx-pingpong.rb → pingpong.rb} +7 -5
  24. data/examples/core/{xx-recurrent-timer.rb → recurrent-timer.rb} +1 -1
  25. data/examples/core/{xx-resource_delegate.rb → resource_delegate.rb} +3 -4
  26. data/examples/core/{01-spinning-up-fibers.rb → spin.rb} +1 -1
  27. data/examples/core/{xx-spin_error_backtrace.rb → spin_error_backtrace.rb} +1 -1
  28. data/examples/core/{xx-supervise-process.rb → supervise-process.rb} +8 -5
  29. data/examples/core/supervisor.rb +20 -0
  30. data/examples/core/{xx-thread-sleep.rb → thread-sleep.rb} +0 -0
  31. data/examples/core/{xx-thread_pool.rb → thread_pool.rb} +0 -0
  32. data/examples/core/{xx-throttling.rb → throttling.rb} +0 -0
  33. data/examples/core/{xx-timeout.rb → timeout.rb} +0 -0
  34. data/examples/core/{xx-using-a-mutex.rb → using-a-mutex.rb} +0 -0
  35. data/examples/core/{xx-worker-thread.rb → worker-thread.rb} +2 -2
  36. data/examples/io/{xx-backticks.rb → backticks.rb} +0 -0
  37. data/examples/io/{xx-echo_client.rb → echo_client.rb} +1 -1
  38. data/examples/io/{xx-echo_client_from_stdin.rb → echo_client_from_stdin.rb} +2 -2
  39. data/examples/io/{xx-echo_pipe.rb → echo_pipe.rb} +1 -1
  40. data/examples/io/{xx-echo_server.rb → echo_server.rb} +0 -0
  41. data/examples/io/{xx-echo_server_with_timeout.rb → echo_server_with_timeout.rb} +1 -1
  42. data/examples/io/{xx-echo_stdin.rb → echo_stdin.rb} +0 -0
  43. data/examples/io/{xx-happy-eyeballs.rb → happy-eyeballs.rb} +0 -0
  44. data/examples/io/{xx-httparty.rb → httparty.rb} +4 -13
  45. data/examples/io/{xx-irb.rb → irb.rb} +0 -0
  46. data/examples/io/{xx-net-http.rb → net-http.rb} +0 -0
  47. data/examples/io/{xx-open.rb → open.rb} +0 -0
  48. data/examples/io/pry.rb +18 -0
  49. data/examples/io/rack_server.rb +71 -0
  50. data/examples/io/{xx-system.rb → system.rb} +1 -1
  51. data/examples/io/{xx-tcpserver.rb → tcpserver.rb} +0 -0
  52. data/examples/io/{xx-tcpsocket.rb → tcpsocket.rb} +0 -0
  53. data/examples/io/tunnel.rb +6 -1
  54. data/examples/io/{xx-zip.rb → zip.rb} +0 -0
  55. data/examples/performance/fiber_transfer.rb +2 -1
  56. data/examples/performance/fs_read.rb +5 -6
  57. data/examples/{io/xx-switch.rb → performance/switch.rb} +2 -1
  58. data/examples/performance/thread-vs-fiber/{xx-httparty_multi.rb → httparty_multi.rb} +3 -4
  59. data/examples/performance/thread-vs-fiber/{xx-httparty_threaded.rb → httparty_threaded.rb} +0 -0
  60. data/examples/performance/thread-vs-fiber/polyphony_mt_server.rb +1 -1
  61. data/examples/performance/thread-vs-fiber/polyphony_server.rb +1 -1
  62. data/examples/performance/thread-vs-fiber/polyphony_server_read_loop.rb +1 -1
  63. data/examples/performance/thread-vs-fiber/threaded_server.rb +1 -5
  64. data/examples/performance/thread_pool_perf.rb +6 -7
  65. data/ext/polyphony/backend.h +40 -0
  66. data/ext/polyphony/event.c +3 -3
  67. data/ext/polyphony/extconf.rb +1 -1
  68. data/ext/polyphony/fiber.c +66 -6
  69. data/ext/polyphony/{libev_agent.c → libev_backend.c} +239 -235
  70. data/ext/polyphony/polyphony.c +3 -3
  71. data/ext/polyphony/polyphony.h +15 -23
  72. data/ext/polyphony/polyphony_ext.c +3 -4
  73. data/ext/polyphony/queue.c +25 -12
  74. data/ext/polyphony/ring_buffer.c +0 -1
  75. data/ext/polyphony/thread.c +36 -33
  76. data/lib/polyphony.rb +25 -38
  77. data/lib/polyphony/adapters/fs.rb +1 -1
  78. data/lib/polyphony/adapters/irb.rb +2 -17
  79. data/lib/polyphony/adapters/mysql2.rb +19 -0
  80. data/lib/polyphony/adapters/postgres.rb +5 -5
  81. data/lib/polyphony/adapters/process.rb +2 -2
  82. data/lib/polyphony/adapters/readline.rb +17 -0
  83. data/lib/polyphony/adapters/redis.rb +1 -1
  84. data/lib/polyphony/adapters/sequel.rb +45 -0
  85. data/lib/polyphony/core/exceptions.rb +11 -0
  86. data/lib/polyphony/core/global_api.rb +17 -12
  87. data/lib/polyphony/core/resource_pool.rb +20 -7
  88. data/lib/polyphony/core/sync.rb +46 -8
  89. data/lib/polyphony/core/throttler.rb +1 -1
  90. data/lib/polyphony/extensions/core.rb +38 -25
  91. data/lib/polyphony/extensions/fiber.rb +12 -45
  92. data/lib/polyphony/extensions/io.rb +45 -12
  93. data/lib/polyphony/extensions/openssl.rb +6 -6
  94. data/lib/polyphony/extensions/socket.rb +22 -15
  95. data/lib/polyphony/extensions/thread.rb +6 -5
  96. data/lib/polyphony/net.rb +2 -1
  97. data/lib/polyphony/version.rb +1 -1
  98. data/polyphony.gemspec +7 -3
  99. data/test/helper.rb +1 -1
  100. data/test/{test_agent.rb → test_backend.rb} +22 -22
  101. data/test/test_fiber.rb +28 -11
  102. data/test/test_io.rb +17 -1
  103. data/test/test_kernel.rb +5 -0
  104. data/test/test_resource_pool.rb +50 -16
  105. data/test/test_signal.rb +5 -29
  106. data/test/test_socket.rb +17 -0
  107. data/test/test_sync.rb +52 -0
  108. metadata +126 -98
  109. data/.gitbook.yaml +0 -4
  110. data/examples/adapters/concurrent-ruby.rb +0 -9
  111. data/examples/core/04-handling-signals.rb +0 -19
  112. data/examples/core/xx-agent.rb +0 -102
  113. data/examples/core/xx-at_exit.rb +0 -29
  114. data/examples/core/xx-caller.rb +0 -12
  115. data/examples/core/xx-daemon.rb +0 -14
  116. data/examples/core/xx-deadlock.rb +0 -8
  117. data/examples/core/xx-deferring-an-operation.rb +0 -14
  118. data/examples/core/xx-exception-backtrace.rb +0 -40
  119. data/examples/core/xx-fork-cleanup.rb +0 -22
  120. data/examples/core/xx-fork-spin.rb +0 -42
  121. data/examples/core/xx-fork-terminate.rb +0 -27
  122. data/examples/core/xx-move_on.rb +0 -23
  123. data/examples/core/xx-queue-async.rb +0 -120
  124. data/examples/core/xx-readpartial.rb +0 -18
  125. data/examples/core/xx-signals.rb +0 -16
  126. data/examples/core/xx-sleep-forever.rb +0 -9
  127. data/examples/core/xx-sleeping.rb +0 -25
  128. data/examples/core/xx-snooze-starve.rb +0 -16
  129. data/examples/core/xx-spin-fork.rb +0 -49
  130. data/examples/core/xx-state-machine.rb +0 -51
  131. data/examples/core/xx-stop.rb +0 -20
  132. data/examples/core/xx-supervisors.rb +0 -21
  133. data/examples/core/xx-thread-selector-sleep.rb +0 -51
  134. data/examples/core/xx-thread-selector-snooze.rb +0 -46
  135. data/examples/core/xx-thread-snooze.rb +0 -34
  136. data/examples/core/xx-timer-gc.rb +0 -17
  137. data/examples/core/xx-trace.rb +0 -79
  138. data/examples/performance/xx-array.rb +0 -11
  139. data/examples/performance/xx-fiber-switch.rb +0 -9
  140. data/examples/performance/xx-snooze.rb +0 -15
  141. data/examples/xx-spin.rb +0 -32
  142. data/ext/polyphony/agent.h +0 -39
@@ -352,7 +352,7 @@ class FiberTest < MiniTest::Test
352
352
  result = []
353
353
  f = Fiber.current.spin do
354
354
  result << :start
355
- result << Thread.current.agent.sleep(1)
355
+ result << Thread.current.backend.sleep(1)
356
356
  end
357
357
  snooze
358
358
  f.interrupt
@@ -413,6 +413,22 @@ class FiberTest < MiniTest::Test
413
413
  f2&.stop
414
414
  end
415
415
 
416
+ def test_interject
417
+ buf = []
418
+ f = spin_loop { sleep }
419
+ snooze
420
+ f.interject { buf << Fiber.current }
421
+ snooze
422
+ assert_equal [f], buf
423
+ assert_equal :waiting, f.state
424
+
425
+ f.interject { buf << :foo; raise Polyphony::MoveOn }
426
+ snooze
427
+
428
+ assert_equal [f, :foo], buf
429
+ assert_equal :dead, f.state
430
+ end
431
+
416
432
  def test_state
417
433
  counter = 0
418
434
  f = spin do
@@ -625,7 +641,7 @@ class FiberTest < MiniTest::Test
625
641
  end
626
642
  end
627
643
  sleep 0.1
628
- f = spin { Thread.current.agent.waitpid(pid) }
644
+ f = spin { Thread.current.backend.waitpid(pid) }
629
645
  o.close
630
646
  Process.kill('INT', pid)
631
647
  f.await
@@ -647,7 +663,7 @@ class FiberTest < MiniTest::Test
647
663
  end
648
664
  end
649
665
  sleep 0.2
650
- f = spin { Thread.current.agent.waitpid(pid) }
666
+ f = spin { Thread.current.backend.waitpid(pid) }
651
667
  o.close
652
668
  Process.kill('TERM', pid)
653
669
  f.await
@@ -674,7 +690,7 @@ class FiberTest < MiniTest::Test
674
690
  sleep 0.2
675
691
  Process.kill('TERM', pid)
676
692
  end
677
- Thread.current.agent.waitpid(pid)
693
+ Thread.current.backend.waitpid(pid)
678
694
  klass = i.read
679
695
  i.close
680
696
  assert_equal 'Polyphony::Terminate', klass
@@ -684,13 +700,14 @@ class FiberTest < MiniTest::Test
684
700
  buffer = []
685
701
  f = Fiber.new { buffer << receive }
686
702
 
687
- assert_raises(NoMethodError) { f << 'foo' }
703
+ assert_nil f.thread
688
704
  snooze
689
705
  f.setup_raw
690
706
  assert_equal Thread.current, f.thread
691
707
  assert_nil f.parent
692
708
 
693
709
  f.schedule
710
+ snooze
694
711
  f << 'bar'
695
712
  snooze
696
713
  assert_equal ['bar'], buffer
@@ -795,20 +812,20 @@ class MailboxTest < MiniTest::Test
795
812
  assert_equal ['foo'] * 100, messages
796
813
  end
797
814
 
798
- def test_receive_pending
799
- assert_equal [], receive_pending
815
+ def test_receive_all_pending
816
+ assert_equal [], receive_all_pending
800
817
 
801
818
  (1..5).each { |i| Fiber.current << i }
802
- assert_equal (1..5).to_a, receive_pending
803
- assert_equal [], receive_pending
819
+ assert_equal (1..5).to_a, receive_all_pending
820
+ assert_equal [], receive_all_pending
804
821
  end
805
822
 
806
- def test_receive_pending_on_termination
823
+ def test_receive_all_pending_on_termination
807
824
  buffer = []
808
825
  worker = spin do
809
826
  loop { buffer << receive }
810
827
  rescue Polyphony::Terminate
811
- receive_pending.each { |r| buffer << r }
828
+ receive_all_pending.each { |r| buffer << r }
812
829
  end
813
830
 
814
831
  worker << 1
@@ -55,7 +55,7 @@ class IOTest < MiniTest::Test
55
55
  results << result
56
56
  case result
57
57
  when :wait_readable
58
- Thread.current.agent.wait_io(i, false)
58
+ Thread.current.backend.wait_io(i, false)
59
59
  else
60
60
  break result
61
61
  end
@@ -246,4 +246,20 @@ class IOClassMethodsTest < MiniTest::Test
246
246
  assert_equal 1e6, s.bytesize
247
247
  assert s == IO.orig_read(fn)
248
248
  end
249
+
250
+ def pipe_read
251
+ i, o = IO.pipe
252
+ yield o
253
+ o.close
254
+ i.read
255
+ ensure
256
+ i.close
257
+ end
258
+
259
+ def test_puts
260
+ assert_equal "foo\n", pipe_read { |f| f.puts 'foo' }
261
+ assert_equal "foo\n", pipe_read { |f| f.puts "foo\n" }
262
+ assert_equal "foo\nbar\n", pipe_read { |f| f.puts 'foo', 'bar' }
263
+ assert_equal "foo\nbar\n", pipe_read { |f| f.puts 'foo', "bar\n" }
264
+ end
249
265
  end
@@ -19,6 +19,11 @@ class KernelTest < MiniTest::Test
19
19
  timer&.stop
20
20
  end
21
21
 
22
+ def test_Kernel_system_singleton_method
23
+ assert_equal true, Kernel.system("which ruby > /dev/null 2>&1")
24
+ assert_equal false, Kernel.system("which rruubbyy > /dev/null 2>&1")
25
+ end
26
+
22
27
  def patch_open3
23
28
  class << Open3
24
29
  alias_method :orig_popen2, :popen2
@@ -12,29 +12,40 @@ class ResourcePoolTest < MiniTest::Test
12
12
  assert_equal 0, pool.size
13
13
 
14
14
  results = []
15
- 4.times {
16
- spin {
17
- snooze
15
+ 4.times { |i|
16
+ spin(:"foo#{i}") {
18
17
  pool.acquire { |resource|
19
18
  results << resource
20
19
  snooze
21
20
  }
22
21
  }
23
22
  }
24
- 2.times { snooze }
23
+ Fiber.current.await_all_children
25
24
  assert_equal 2, pool.limit
26
- assert_equal 0, pool.available
25
+ assert_equal 2, pool.available
27
26
  assert_equal 2, pool.size
28
-
29
- 2.times { snooze }
30
-
31
27
  assert_equal ['a', 'b', 'a', 'b'], results
28
+ end
32
29
 
33
- 2.times { snooze }
30
+ def test_discard
31
+ resources = [+'a', +'b']
32
+ pool = Polyphony::ResourcePool.new(limit: 2) { resources.shift }
34
33
 
35
- assert_equal 2, pool.limit
36
- assert_equal 2, pool.available
37
- assert_equal 2, pool.size
34
+ results = []
35
+ 4.times {
36
+ spin {
37
+ snooze
38
+ pool.acquire { |resource|
39
+ results << resource
40
+ pool.discard! if resource == 'b'
41
+ snooze
42
+ }
43
+ }
44
+ }
45
+ Fiber.current.await_all_children
46
+
47
+ assert_equal ['a', 'b', 'a', 'a'], results
48
+ assert_equal 1, pool.size
38
49
  end
39
50
 
40
51
  def test_single_resource_limit
@@ -51,7 +62,7 @@ class ResourcePoolTest < MiniTest::Test
51
62
  }
52
63
  }
53
64
  }
54
- 20.times { snooze }
65
+ Fiber.current.await_all_children
55
66
 
56
67
  assert_equal ['a'] * 10, results
57
68
  end
@@ -85,11 +96,34 @@ class ResourcePoolTest < MiniTest::Test
85
96
  resources = [+'a', +'b']
86
97
  pool = Polyphony::ResourcePool.new(limit: 1) { resources.shift }
87
98
 
99
+ results = []
88
100
  pool.acquire do |r|
89
- assert_equal 'a', r
90
- pool.acquire do |r|
91
- assert_equal 'a', r
101
+ results << r
102
+ 2.times do
103
+ pool.acquire do |r|
104
+ results << r
105
+ end
92
106
  end
93
107
  end
108
+ assert_equal ['a']*3, results
109
+ end
110
+
111
+ def test_overloaded_resource_pool
112
+ pool = Polyphony::ResourcePool.new(limit: 1) { 1 }
113
+
114
+ buf = []
115
+ fibers = 2.times.map do |i|
116
+ spin(:"foo#{i}") do
117
+ 2.times do
118
+ pool.acquire do |r|
119
+ buf << r
120
+ snooze
121
+ end
122
+ end
123
+ end
124
+ end
125
+ Fiber.current.await_all_children
126
+
127
+ assert_equal [1, 1, 1, 1], buf
94
128
  end
95
129
  end
@@ -23,7 +23,7 @@ class SignalTrapTest < Minitest::Test
23
23
  sleep 0.01
24
24
  o.close
25
25
  Process.kill('INT', pid)
26
- Thread.current.agent.waitpid(pid)
26
+ Thread.current.backend.waitpid(pid)
27
27
  buffer = i.read
28
28
  assert_equal "3-interrupt\n", buffer
29
29
  end
@@ -51,40 +51,16 @@ class SignalTrapTest < Minitest::Test
51
51
  sleep 0.02
52
52
  o.close
53
53
  Process.kill('INT', pid)
54
- Thread.current.agent.waitpid(pid)
54
+ Thread.current.backend.waitpid(pid)
55
55
  buffer = i.read
56
56
  assert_equal "3 - interrupted\n2 - terminated\n1 - terminated\n", buffer
57
57
  end
58
58
 
59
- def test_signal_exception_possible_race_condition
59
+ def test_interrupt_signal_scheduling
60
60
  i, o = IO.pipe
61
61
  pid = Polyphony.fork do
62
62
  i.close
63
- f1 = nil
64
- f2 = spin do
65
- # this fiber will try to create a race condition by
66
- # - being scheduled before f1 is scheduled with the Interrupt exception
67
- # - scheduling f1 without an exception
68
- suspend
69
- f1.schedule
70
- rescue ::Interrupt => e
71
- o.puts '2-interrupt'
72
- raise e
73
- end
74
- f1 = spin do
75
- # this fiber is the one that will be current when the
76
- # signal is trapped
77
- sleep 1
78
- o << 'boom'
79
- rescue ::Interrupt => e
80
- o.puts '1-interrupt'
81
- raise e
82
- end
83
- old_trap = trap('INT') do
84
- f2.schedule
85
- old_trap.()
86
- end
87
- Fiber.current.await_all_children
63
+ sleep
88
64
  rescue ::Interrupt => e
89
65
  o.puts '3-interrupt'
90
66
  ensure
@@ -93,7 +69,7 @@ class SignalTrapTest < Minitest::Test
93
69
  o.close
94
70
  sleep 0.1
95
71
  Process.kill('INT', pid)
96
- Thread.current.agent.waitpid(pid)
72
+ Thread.current.backend.waitpid(pid)
97
73
  buffer = i.read
98
74
  assert_equal "3-interrupt\n", buffer
99
75
  end
@@ -32,3 +32,20 @@ class SocketTest < MiniTest::Test
32
32
  server&.close
33
33
  end
34
34
  end
35
+
36
+ class HTTPClientTest < MiniTest::Test
37
+ require 'httparty'
38
+ require 'json'
39
+
40
+ def test_http
41
+ res = HTTParty.get('http://worldtimeapi.org/api/timezone/Europe/Paris')
42
+ response = JSON.load(res.body)
43
+ assert_equal "CEST", response['abbreviation']
44
+ end
45
+
46
+ def test_https
47
+ res = HTTParty.get('https://worldtimeapi.org/api/timezone/Europe/Paris')
48
+ response = JSON.load(res.body)
49
+ assert_equal "CEST", response['abbreviation']
50
+ end
51
+ end
@@ -0,0 +1,52 @@
1
+ # frozen_string_literal: true
2
+
3
+ require_relative 'helper'
4
+
5
+ class MutexTest < MiniTest::Test
6
+ def test_mutex
7
+ buf = []
8
+ lock = Polyphony::Mutex.new
9
+ (1..3).each do |i|
10
+ spin do
11
+ lock.synchronize do
12
+ buf << ">> #{i}"
13
+ sleep(rand * 0.05)
14
+ buf << "<< #{i}"
15
+ end
16
+ end
17
+ end
18
+
19
+ Fiber.current.await_all_children
20
+ assert_equal ['>> 1', '<< 1', '>> 2', '<< 2', '>> 3', '<< 3'], buf
21
+ end
22
+
23
+ def test_condition_variable
24
+ buf = []
25
+ lock1 = Polyphony::Mutex.new
26
+ lock2 = Polyphony::Mutex.new
27
+ cond = Polyphony::ConditionVariable.new
28
+
29
+ spin do
30
+ lock1.synchronize do
31
+ sleep 0.01
32
+ cond.wait(lock1)
33
+ lock2.synchronize do
34
+ buf << :foo
35
+ end
36
+ end
37
+ end
38
+
39
+ spin do
40
+ lock2.synchronize do
41
+ sleep 0.01
42
+ lock1.synchronize do
43
+ buf << :bar
44
+ end
45
+ cond.signal
46
+ end
47
+ end
48
+
49
+ Fiber.current.await_all_children
50
+ assert_equal [:bar, :foo], buf
51
+ end
52
+ end
metadata CHANGED
@@ -1,43 +1,29 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: polyphony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.43.10
4
+ version: 0.45.2
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-07-23 00:00:00.000000000 Z
11
+ date: 2020-08-03 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
- name: httparty
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - '='
18
- - !ruby/object:Gem::Version
19
- version: 0.17.0
20
- type: :development
21
- prerelease: false
22
- version_requirements: !ruby/object:Gem::Requirement
23
- requirements:
24
- - - '='
25
- - !ruby/object:Gem::Version
26
- version: 0.17.0
27
- - !ruby/object:Gem::Dependency
28
- name: localhost
14
+ name: rake-compiler
29
15
  requirement: !ruby/object:Gem::Requirement
30
16
  requirements:
31
17
  - - '='
32
18
  - !ruby/object:Gem::Version
33
- version: 1.1.4
19
+ version: 1.0.5
34
20
  type: :development
35
21
  prerelease: false
36
22
  version_requirements: !ruby/object:Gem::Requirement
37
23
  requirements:
38
24
  - - '='
39
25
  - !ruby/object:Gem::Version
40
- version: 1.1.4
26
+ version: 1.0.5
41
27
  - !ruby/object:Gem::Dependency
42
28
  name: minitest
43
29
  requirement: !ruby/object:Gem::Requirement
@@ -95,33 +81,33 @@ dependencies:
95
81
  - !ruby/object:Gem::Version
96
82
  version: 0.85.1
97
83
  - !ruby/object:Gem::Dependency
98
- name: pg
84
+ name: pry
99
85
  requirement: !ruby/object:Gem::Requirement
100
86
  requirements:
101
87
  - - '='
102
88
  - !ruby/object:Gem::Version
103
- version: 1.1.4
89
+ version: 0.13.1
104
90
  type: :development
105
91
  prerelease: false
106
92
  version_requirements: !ruby/object:Gem::Requirement
107
93
  requirements:
108
94
  - - '='
109
95
  - !ruby/object:Gem::Version
110
- version: 1.1.4
96
+ version: 0.13.1
111
97
  - !ruby/object:Gem::Dependency
112
- name: rake-compiler
98
+ name: pg
113
99
  requirement: !ruby/object:Gem::Requirement
114
100
  requirements:
115
101
  - - '='
116
102
  - !ruby/object:Gem::Version
117
- version: 1.0.5
103
+ version: 1.1.4
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
107
  requirements:
122
108
  - - '='
123
109
  - !ruby/object:Gem::Version
124
- version: 1.0.5
110
+ version: 1.1.4
125
111
  - !ruby/object:Gem::Dependency
126
112
  name: redis
127
113
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +150,68 @@ dependencies:
164
150
  - - "~>"
165
151
  - !ruby/object:Gem::Version
166
152
  version: 0.6.0
153
+ - !ruby/object:Gem::Dependency
154
+ name: rack
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - ">="
158
+ - !ruby/object:Gem::Version
159
+ version: 2.0.8
160
+ - - "<"
161
+ - !ruby/object:Gem::Version
162
+ version: 2.3.0
163
+ type: :development
164
+ prerelease: false
165
+ version_requirements: !ruby/object:Gem::Requirement
166
+ requirements:
167
+ - - ">="
168
+ - !ruby/object:Gem::Version
169
+ version: 2.0.8
170
+ - - "<"
171
+ - !ruby/object:Gem::Version
172
+ version: 2.3.0
173
+ - !ruby/object:Gem::Dependency
174
+ name: mysql2
175
+ requirement: !ruby/object:Gem::Requirement
176
+ requirements:
177
+ - - '='
178
+ - !ruby/object:Gem::Version
179
+ version: 0.5.3
180
+ type: :development
181
+ prerelease: false
182
+ version_requirements: !ruby/object:Gem::Requirement
183
+ requirements:
184
+ - - '='
185
+ - !ruby/object:Gem::Version
186
+ version: 0.5.3
187
+ - !ruby/object:Gem::Dependency
188
+ name: sequel
189
+ requirement: !ruby/object:Gem::Requirement
190
+ requirements:
191
+ - - '='
192
+ - !ruby/object:Gem::Version
193
+ version: 5.34.0
194
+ type: :development
195
+ prerelease: false
196
+ version_requirements: !ruby/object:Gem::Requirement
197
+ requirements:
198
+ - - '='
199
+ - !ruby/object:Gem::Version
200
+ version: 5.34.0
201
+ - !ruby/object:Gem::Dependency
202
+ name: httparty
203
+ requirement: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - '='
206
+ - !ruby/object:Gem::Version
207
+ version: 0.17.1
208
+ type: :development
209
+ prerelease: false
210
+ version_requirements: !ruby/object:Gem::Requirement
211
+ requirements:
212
+ - - '='
213
+ - !ruby/object:Gem::Version
214
+ version: 0.17.1
167
215
  - !ruby/object:Gem::Dependency
168
216
  name: jekyll
169
217
  requirement: !ruby/object:Gem::Requirement
@@ -228,7 +276,6 @@ extensions:
228
276
  extra_rdoc_files:
229
277
  - README.md
230
278
  files:
231
- - ".gitbook.yaml"
232
279
  - ".github/workflows/test.yml"
233
280
  - ".gitignore"
234
281
  - ".rubocop.yml"
@@ -245,6 +292,7 @@ files:
245
292
  - docs/_config.yml
246
293
  - docs/_includes/head.html
247
294
  - docs/_includes/title.html
295
+ - docs/_posts/2020-07-26-polyphony-0.44.md
248
296
  - docs/_sass/custom/custom.scss
249
297
  - docs/_sass/overrides.scss
250
298
  - docs/_user-guide/all-about-timers.md
@@ -283,7 +331,6 @@ files:
283
331
  - docs/main-concepts/fiber-scheduling.md
284
332
  - docs/main-concepts/index.md
285
333
  - docs/polyphony-logo.png
286
- - examples/adapters/concurrent-ruby.rb
287
334
  - examples/adapters/pg_client.rb
288
335
  - examples/adapters/pg_notify.rb
289
336
  - examples/adapters/pg_pool.rb
@@ -293,68 +340,48 @@ files:
293
340
  - examples/adapters/redis_client.rb
294
341
  - examples/adapters/redis_pubsub.rb
295
342
  - examples/adapters/redis_pubsub_perf.rb
296
- - examples/core/01-spinning-up-fibers.rb
297
- - examples/core/02-awaiting-fibers.rb
298
- - examples/core/03-interrupting.rb
299
- - examples/core/04-handling-signals.rb
300
- - examples/core/xx-agent.rb
301
- - examples/core/xx-at_exit.rb
302
- - examples/core/xx-caller.rb
303
- - examples/core/xx-channels.rb
304
- - examples/core/xx-daemon.rb
305
- - examples/core/xx-deadlock.rb
306
- - examples/core/xx-deferring-an-operation.rb
307
- - examples/core/xx-erlang-style-genserver.rb
308
- - examples/core/xx-exception-backtrace.rb
309
- - examples/core/xx-fork-cleanup.rb
310
- - examples/core/xx-fork-spin.rb
311
- - examples/core/xx-fork-terminate.rb
312
- - examples/core/xx-forking.rb
313
- - examples/core/xx-move_on.rb
314
- - examples/core/xx-pingpong.rb
315
- - examples/core/xx-queue-async.rb
316
- - examples/core/xx-readpartial.rb
317
- - examples/core/xx-recurrent-timer.rb
318
- - examples/core/xx-resource_delegate.rb
319
- - examples/core/xx-signals.rb
320
- - examples/core/xx-sleep-forever.rb
321
- - examples/core/xx-sleeping.rb
322
- - examples/core/xx-snooze-starve.rb
323
- - examples/core/xx-spin-fork.rb
324
- - examples/core/xx-spin_error_backtrace.rb
325
- - examples/core/xx-state-machine.rb
326
- - examples/core/xx-stop.rb
327
- - examples/core/xx-supervise-process.rb
328
- - examples/core/xx-supervisors.rb
329
- - examples/core/xx-thread-selector-sleep.rb
330
- - examples/core/xx-thread-selector-snooze.rb
331
- - examples/core/xx-thread-sleep.rb
332
- - examples/core/xx-thread-snooze.rb
333
- - examples/core/xx-thread_pool.rb
334
- - examples/core/xx-throttling.rb
335
- - examples/core/xx-timeout.rb
336
- - examples/core/xx-timer-gc.rb
337
- - examples/core/xx-trace.rb
338
- - examples/core/xx-using-a-mutex.rb
339
- - examples/core/xx-worker-thread.rb
343
+ - examples/adapters/sequel_mysql.rb
344
+ - examples/adapters/sequel_mysql_pool.rb
345
+ - examples/adapters/sequel_pg.rb
346
+ - examples/core/await.rb
347
+ - examples/core/channels.rb
348
+ - examples/core/deferring-an-operation.rb
349
+ - examples/core/erlang-style-genserver.rb
350
+ - examples/core/forking.rb
351
+ - examples/core/handling-signals.rb
352
+ - examples/core/interrupt.rb
353
+ - examples/core/pingpong.rb
354
+ - examples/core/recurrent-timer.rb
355
+ - examples/core/resource_delegate.rb
356
+ - examples/core/spin.rb
357
+ - examples/core/spin_error_backtrace.rb
358
+ - examples/core/supervise-process.rb
359
+ - examples/core/supervisor.rb
360
+ - examples/core/thread-sleep.rb
361
+ - examples/core/thread_pool.rb
362
+ - examples/core/throttling.rb
363
+ - examples/core/timeout.rb
364
+ - examples/core/using-a-mutex.rb
365
+ - examples/core/worker-thread.rb
366
+ - examples/io/backticks.rb
367
+ - examples/io/echo_client.rb
368
+ - examples/io/echo_client_from_stdin.rb
369
+ - examples/io/echo_pipe.rb
370
+ - examples/io/echo_server.rb
371
+ - examples/io/echo_server_with_timeout.rb
372
+ - examples/io/echo_stdin.rb
373
+ - examples/io/happy-eyeballs.rb
374
+ - examples/io/httparty.rb
375
+ - examples/io/irb.rb
376
+ - examples/io/net-http.rb
377
+ - examples/io/open.rb
378
+ - examples/io/pry.rb
379
+ - examples/io/rack_server.rb
380
+ - examples/io/system.rb
381
+ - examples/io/tcpserver.rb
382
+ - examples/io/tcpsocket.rb
340
383
  - examples/io/tunnel.rb
341
- - examples/io/xx-backticks.rb
342
- - examples/io/xx-echo_client.rb
343
- - examples/io/xx-echo_client_from_stdin.rb
344
- - examples/io/xx-echo_pipe.rb
345
- - examples/io/xx-echo_server.rb
346
- - examples/io/xx-echo_server_with_timeout.rb
347
- - examples/io/xx-echo_stdin.rb
348
- - examples/io/xx-happy-eyeballs.rb
349
- - examples/io/xx-httparty.rb
350
- - examples/io/xx-irb.rb
351
- - examples/io/xx-net-http.rb
352
- - examples/io/xx-open.rb
353
- - examples/io/xx-switch.rb
354
- - examples/io/xx-system.rb
355
- - examples/io/xx-tcpserver.rb
356
- - examples/io/xx-tcpsocket.rb
357
- - examples/io/xx-zip.rb
384
+ - examples/io/zip.rb
358
385
  - examples/performance/fiber_transfer.rb
359
386
  - examples/performance/fs_read.rb
360
387
  - examples/performance/mem-usage.rb
@@ -362,17 +389,14 @@ files:
362
389
  - examples/performance/multi_snooze.rb
363
390
  - examples/performance/snooze.rb
364
391
  - examples/performance/snooze_raw.rb
392
+ - examples/performance/switch.rb
393
+ - examples/performance/thread-vs-fiber/httparty_multi.rb
394
+ - examples/performance/thread-vs-fiber/httparty_threaded.rb
365
395
  - examples/performance/thread-vs-fiber/polyphony_mt_server.rb
366
396
  - examples/performance/thread-vs-fiber/polyphony_server.rb
367
397
  - examples/performance/thread-vs-fiber/polyphony_server_read_loop.rb
368
398
  - examples/performance/thread-vs-fiber/threaded_server.rb
369
- - examples/performance/thread-vs-fiber/xx-httparty_multi.rb
370
- - examples/performance/thread-vs-fiber/xx-httparty_threaded.rb
371
399
  - examples/performance/thread_pool_perf.rb
372
- - examples/performance/xx-array.rb
373
- - examples/performance/xx-fiber-switch.rb
374
- - examples/performance/xx-snooze.rb
375
- - examples/xx-spin.rb
376
400
  - ext/libev/Changes
377
401
  - ext/libev/LICENSE
378
402
  - ext/libev/README
@@ -389,13 +413,13 @@ files:
389
413
  - ext/libev/ev_win32.c
390
414
  - ext/libev/ev_wrap.h
391
415
  - ext/libev/test_libev_win32.c
392
- - ext/polyphony/agent.h
416
+ - ext/polyphony/backend.h
393
417
  - ext/polyphony/event.c
394
418
  - ext/polyphony/extconf.rb
395
419
  - ext/polyphony/fiber.c
396
420
  - ext/polyphony/libev.c
397
421
  - ext/polyphony/libev.h
398
- - ext/polyphony/libev_agent.c
422
+ - ext/polyphony/libev_backend.c
399
423
  - ext/polyphony/polyphony.c
400
424
  - ext/polyphony/polyphony.h
401
425
  - ext/polyphony/polyphony_ext.c
@@ -407,9 +431,12 @@ files:
407
431
  - lib/polyphony.rb
408
432
  - lib/polyphony/adapters/fs.rb
409
433
  - lib/polyphony/adapters/irb.rb
434
+ - lib/polyphony/adapters/mysql2.rb
410
435
  - lib/polyphony/adapters/postgres.rb
411
436
  - lib/polyphony/adapters/process.rb
437
+ - lib/polyphony/adapters/readline.rb
412
438
  - lib/polyphony/adapters/redis.rb
439
+ - lib/polyphony/adapters/sequel.rb
413
440
  - lib/polyphony/adapters/trace.rb
414
441
  - lib/polyphony/core/channel.rb
415
442
  - lib/polyphony/core/exceptions.rb
@@ -433,7 +460,7 @@ files:
433
460
  - test/q.rb
434
461
  - test/run.rb
435
462
  - test/stress.rb
436
- - test/test_agent.rb
463
+ - test/test_backend.rb
437
464
  - test/test_event.rb
438
465
  - test/test_ext.rb
439
466
  - test/test_fiber.rb
@@ -446,6 +473,7 @@ files:
446
473
  - test/test_signal.rb
447
474
  - test/test_socket.rb
448
475
  - test/test_supervise.rb
476
+ - test/test_sync.rb
449
477
  - test/test_thread.rb
450
478
  - test/test_thread_pool.rb
451
479
  - test/test_throttler.rb
@@ -477,7 +505,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
477
505
  - !ruby/object:Gem::Version
478
506
  version: '0'
479
507
  requirements: []
480
- rubygems_version: 3.0.8
508
+ rubygems_version: 3.1.2
481
509
  signing_key:
482
510
  specification_version: 4
483
511
  summary: Fine grained concurrency for Ruby