concurrent-ruby 0.8.0 → 0.9.0.pre2

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 (144) hide show
  1. checksums.yaml +4 -4
  2. data/CHANGELOG.md +97 -2
  3. data/README.md +103 -54
  4. data/lib/concurrent.rb +34 -14
  5. data/lib/concurrent/async.rb +164 -50
  6. data/lib/concurrent/atom.rb +171 -0
  7. data/lib/concurrent/atomic/atomic_boolean.rb +57 -107
  8. data/lib/concurrent/atomic/atomic_fixnum.rb +73 -101
  9. data/lib/concurrent/atomic/atomic_reference.rb +49 -0
  10. data/lib/concurrent/atomic/condition.rb +23 -12
  11. data/lib/concurrent/atomic/count_down_latch.rb +23 -21
  12. data/lib/concurrent/atomic/cyclic_barrier.rb +47 -47
  13. data/lib/concurrent/atomic/event.rb +33 -42
  14. data/lib/concurrent/atomic/read_write_lock.rb +252 -0
  15. data/lib/concurrent/atomic/semaphore.rb +64 -89
  16. data/lib/concurrent/atomic/thread_local_var.rb +130 -58
  17. data/lib/concurrent/atomic/thread_local_var/weak_key_map.rb +236 -0
  18. data/lib/concurrent/atomic_reference/direct_update.rb +3 -0
  19. data/lib/concurrent/atomic_reference/jruby.rb +6 -3
  20. data/lib/concurrent/atomic_reference/mutex_atomic.rb +10 -32
  21. data/lib/concurrent/atomic_reference/numeric_cas_wrapper.rb +3 -0
  22. data/lib/concurrent/atomic_reference/rbx.rb +4 -1
  23. data/lib/concurrent/atomic_reference/ruby.rb +6 -3
  24. data/lib/concurrent/atomics.rb +74 -4
  25. data/lib/concurrent/collection/copy_on_notify_observer_set.rb +115 -0
  26. data/lib/concurrent/collection/copy_on_write_observer_set.rb +119 -0
  27. data/lib/concurrent/collection/priority_queue.rb +300 -245
  28. data/lib/concurrent/concern/deprecation.rb +27 -0
  29. data/lib/concurrent/concern/dereferenceable.rb +88 -0
  30. data/lib/concurrent/concern/logging.rb +25 -0
  31. data/lib/concurrent/concern/obligation.rb +228 -0
  32. data/lib/concurrent/concern/observable.rb +85 -0
  33. data/lib/concurrent/configuration.rb +226 -112
  34. data/lib/concurrent/dataflow.rb +2 -3
  35. data/lib/concurrent/delay.rb +141 -50
  36. data/lib/concurrent/edge.rb +30 -0
  37. data/lib/concurrent/errors.rb +10 -0
  38. data/lib/concurrent/exchanger.rb +25 -1
  39. data/lib/concurrent/executor/cached_thread_pool.rb +46 -33
  40. data/lib/concurrent/executor/executor.rb +46 -299
  41. data/lib/concurrent/executor/executor_service.rb +521 -0
  42. data/lib/concurrent/executor/fixed_thread_pool.rb +206 -26
  43. data/lib/concurrent/executor/immediate_executor.rb +9 -9
  44. data/lib/concurrent/executor/indirect_immediate_executor.rb +4 -3
  45. data/lib/concurrent/executor/java_cached_thread_pool.rb +18 -16
  46. data/lib/concurrent/executor/java_fixed_thread_pool.rb +11 -18
  47. data/lib/concurrent/executor/java_single_thread_executor.rb +17 -16
  48. data/lib/concurrent/executor/java_thread_pool_executor.rb +55 -102
  49. data/lib/concurrent/executor/ruby_cached_thread_pool.rb +9 -18
  50. data/lib/concurrent/executor/ruby_fixed_thread_pool.rb +10 -21
  51. data/lib/concurrent/executor/ruby_single_thread_executor.rb +14 -16
  52. data/lib/concurrent/executor/ruby_thread_pool_executor.rb +250 -166
  53. data/lib/concurrent/executor/safe_task_executor.rb +5 -4
  54. data/lib/concurrent/executor/serialized_execution.rb +22 -18
  55. data/lib/concurrent/executor/{per_thread_executor.rb → simple_executor_service.rb} +29 -20
  56. data/lib/concurrent/executor/single_thread_executor.rb +32 -21
  57. data/lib/concurrent/executor/thread_pool_executor.rb +72 -60
  58. data/lib/concurrent/executor/timer_set.rb +96 -84
  59. data/lib/concurrent/executors.rb +1 -1
  60. data/lib/concurrent/future.rb +70 -38
  61. data/lib/concurrent/immutable_struct.rb +89 -0
  62. data/lib/concurrent/ivar.rb +152 -60
  63. data/lib/concurrent/lazy_register.rb +40 -20
  64. data/lib/concurrent/maybe.rb +226 -0
  65. data/lib/concurrent/mutable_struct.rb +227 -0
  66. data/lib/concurrent/mvar.rb +44 -43
  67. data/lib/concurrent/promise.rb +208 -134
  68. data/lib/concurrent/scheduled_task.rb +339 -43
  69. data/lib/concurrent/settable_struct.rb +127 -0
  70. data/lib/concurrent/synchronization.rb +17 -0
  71. data/lib/concurrent/synchronization/abstract_object.rb +163 -0
  72. data/lib/concurrent/synchronization/abstract_struct.rb +158 -0
  73. data/lib/concurrent/synchronization/condition.rb +53 -0
  74. data/lib/concurrent/synchronization/java_object.rb +35 -0
  75. data/lib/concurrent/synchronization/lock.rb +32 -0
  76. data/lib/concurrent/synchronization/monitor_object.rb +24 -0
  77. data/lib/concurrent/synchronization/mutex_object.rb +43 -0
  78. data/lib/concurrent/synchronization/object.rb +78 -0
  79. data/lib/concurrent/synchronization/rbx_object.rb +75 -0
  80. data/lib/concurrent/timer_task.rb +87 -100
  81. data/lib/concurrent/tvar.rb +42 -38
  82. data/lib/concurrent/utilities.rb +3 -1
  83. data/lib/concurrent/utility/at_exit.rb +97 -0
  84. data/lib/concurrent/utility/engine.rb +40 -0
  85. data/lib/concurrent/utility/monotonic_time.rb +59 -0
  86. data/lib/concurrent/utility/native_extension_loader.rb +56 -0
  87. data/lib/concurrent/utility/processor_counter.rb +156 -0
  88. data/lib/concurrent/utility/timeout.rb +18 -14
  89. data/lib/concurrent/utility/timer.rb +11 -6
  90. data/lib/concurrent/version.rb +2 -1
  91. data/lib/concurrent_ruby.rb +1 -0
  92. metadata +47 -83
  93. data/lib/concurrent/actor.rb +0 -103
  94. data/lib/concurrent/actor/behaviour.rb +0 -70
  95. data/lib/concurrent/actor/behaviour/abstract.rb +0 -48
  96. data/lib/concurrent/actor/behaviour/awaits.rb +0 -21
  97. data/lib/concurrent/actor/behaviour/buffer.rb +0 -54
  98. data/lib/concurrent/actor/behaviour/errors_on_unknown_message.rb +0 -12
  99. data/lib/concurrent/actor/behaviour/executes_context.rb +0 -18
  100. data/lib/concurrent/actor/behaviour/linking.rb +0 -45
  101. data/lib/concurrent/actor/behaviour/pausing.rb +0 -77
  102. data/lib/concurrent/actor/behaviour/removes_child.rb +0 -16
  103. data/lib/concurrent/actor/behaviour/sets_results.rb +0 -36
  104. data/lib/concurrent/actor/behaviour/supervised.rb +0 -59
  105. data/lib/concurrent/actor/behaviour/supervising.rb +0 -34
  106. data/lib/concurrent/actor/behaviour/terminates_children.rb +0 -13
  107. data/lib/concurrent/actor/behaviour/termination.rb +0 -54
  108. data/lib/concurrent/actor/context.rb +0 -154
  109. data/lib/concurrent/actor/core.rb +0 -217
  110. data/lib/concurrent/actor/default_dead_letter_handler.rb +0 -9
  111. data/lib/concurrent/actor/envelope.rb +0 -41
  112. data/lib/concurrent/actor/errors.rb +0 -27
  113. data/lib/concurrent/actor/internal_delegations.rb +0 -49
  114. data/lib/concurrent/actor/public_delegations.rb +0 -40
  115. data/lib/concurrent/actor/reference.rb +0 -81
  116. data/lib/concurrent/actor/root.rb +0 -37
  117. data/lib/concurrent/actor/type_check.rb +0 -48
  118. data/lib/concurrent/actor/utils.rb +0 -10
  119. data/lib/concurrent/actor/utils/ad_hoc.rb +0 -21
  120. data/lib/concurrent/actor/utils/balancer.rb +0 -42
  121. data/lib/concurrent/actor/utils/broadcast.rb +0 -52
  122. data/lib/concurrent/actor/utils/pool.rb +0 -59
  123. data/lib/concurrent/actress.rb +0 -3
  124. data/lib/concurrent/agent.rb +0 -209
  125. data/lib/concurrent/atomic.rb +0 -92
  126. data/lib/concurrent/atomic/copy_on_notify_observer_set.rb +0 -118
  127. data/lib/concurrent/atomic/copy_on_write_observer_set.rb +0 -117
  128. data/lib/concurrent/atomic/synchronization.rb +0 -51
  129. data/lib/concurrent/channel/buffered_channel.rb +0 -85
  130. data/lib/concurrent/channel/channel.rb +0 -41
  131. data/lib/concurrent/channel/unbuffered_channel.rb +0 -35
  132. data/lib/concurrent/channel/waitable_list.rb +0 -40
  133. data/lib/concurrent/channels.rb +0 -5
  134. data/lib/concurrent/collection/blocking_ring_buffer.rb +0 -71
  135. data/lib/concurrent/collection/ring_buffer.rb +0 -59
  136. data/lib/concurrent/collections.rb +0 -3
  137. data/lib/concurrent/dereferenceable.rb +0 -108
  138. data/lib/concurrent/executor/ruby_thread_pool_worker.rb +0 -73
  139. data/lib/concurrent/logging.rb +0 -20
  140. data/lib/concurrent/obligation.rb +0 -171
  141. data/lib/concurrent/observable.rb +0 -73
  142. data/lib/concurrent/options_parser.rb +0 -52
  143. data/lib/concurrent/utility/processor_count.rb +0 -152
  144. data/lib/extension_helper.rb +0 -37
@@ -2,34 +2,38 @@ require 'rbconfig'
2
2
  require 'thread'
3
3
 
4
4
  require 'concurrent/errors'
5
+ require 'concurrent/concern/deprecation'
5
6
 
6
7
  module Concurrent
8
+ extend Concern::Deprecation
7
9
 
8
- # Wait the given number of seconds for the block operation to complete.
10
+ # [DEPRECATED] Wait the given number of seconds for the block operation to complete.
11
+ # Intended to be a simpler and more reliable replacement to the Ruby
12
+ # standard library `Timeout::timeout` method. It does not kill the task
13
+ # so it finishes anyway. Advantage is that it cannot cause any ugly errors by
14
+ # killing threads.
9
15
  #
10
16
  # @param [Integer] seconds The number of seconds to wait
11
- #
12
17
  # @return [Object] The result of the block operation
13
18
  #
14
19
  # @raise [Concurrent::TimeoutError] when the block operation does not complete
15
20
  # in the allotted number of seconds.
16
21
  #
17
- # @note This method is intended to be a simpler and more reliable replacement
18
- # to the Ruby standard library `Timeout::timeout` method.
19
- def timeout(seconds)
20
-
21
- thread = Thread.new do
22
- Thread.current[:result] = yield
23
- end
24
- success = thread.join(seconds)
22
+ # @see http://ruby-doc.org/stdlib-2.2.0/libdoc/timeout/rdoc/Timeout.html Ruby Timeout::timeout
23
+ #
24
+ # @!macro monotonic_clock_warning
25
+ #
26
+ # @deprecated timeout is deprecated and will be removed
27
+ def timeout(seconds, &block)
28
+ deprecated 'timeout is deprecated and will be removed'
25
29
 
26
- if success
27
- return thread[:result]
30
+ future = Future.execute(&block)
31
+ future.wait(seconds)
32
+ if future.complete?
33
+ future.value!
28
34
  else
29
35
  raise TimeoutError
30
36
  end
31
- ensure
32
- Thread.kill(thread) unless thread.nil?
33
37
  end
34
38
  module_function :timeout
35
39
  end
@@ -1,21 +1,26 @@
1
1
  require 'concurrent/configuration'
2
- require 'thread'
2
+ require 'concurrent/concern/deprecation'
3
3
 
4
4
  module Concurrent
5
+ extend Concern::Deprecation
5
6
 
6
- # Perform the given operation asynchronously after the given number of seconds.
7
+ # [DEPRECATED] Perform the given operation asynchronously after
8
+ # the given number of seconds.
7
9
  #
8
10
  # @param [Fixnum] seconds the interval in seconds to wait before executing the task
9
11
  #
10
12
  # @yield the task to execute
11
13
  #
12
- # @return [Boolean] true
14
+ # @return [Concurrent::ScheduledTask] IVar representing the task
15
+ #
16
+ # @see Concurrent::ScheduledTask
17
+ #
18
+ # @deprecated use `ScheduledTask` instead
13
19
  def timer(seconds, *args, &block)
20
+ deprecated_method 'Concurrent.timer', 'ScheduledTask'
14
21
  raise ArgumentError.new('no block given') unless block_given?
15
22
  raise ArgumentError.new('interval must be greater than or equal to zero') if seconds < 0
16
-
17
- Concurrent.configuration.global_timer_set.post(seconds, *args, &block)
18
- true
23
+ Concurrent.global_timer_set.post(seconds, *args, &block)
19
24
  end
20
25
  module_function :timer
21
26
  end
@@ -1,3 +1,4 @@
1
1
  module Concurrent
2
- VERSION = '0.8.0'
2
+ VERSION = '0.9.0.pre2'
3
+ EDGE_VERSION = '0.1.0.pre2'
3
4
  end
@@ -1 +1,2 @@
1
+ warn "'[DEPRECATED] use `require 'concurrent'` instead of `require 'concurrent_ruby'`"
1
2
  require 'concurrent'
metadata CHANGED
@@ -1,39 +1,22 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concurrent-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0
4
+ version: 0.9.0.pre2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry D'Antonio
8
+ - The Ruby Concurrency Team
8
9
  autorequire:
9
10
  bindir: bin
10
11
  cert_chain: []
11
- date: 2015-01-25 00:00:00.000000000 Z
12
- dependencies:
13
- - !ruby/object:Gem::Dependency
14
- name: ref
15
- requirement: !ruby/object:Gem::Requirement
16
- requirements:
17
- - - "~>"
18
- - !ruby/object:Gem::Version
19
- version: '1.0'
20
- - - ">="
21
- - !ruby/object:Gem::Version
22
- version: 1.0.5
23
- type: :runtime
24
- prerelease: false
25
- version_requirements: !ruby/object:Gem::Requirement
26
- requirements:
27
- - - "~>"
28
- - !ruby/object:Gem::Version
29
- version: '1.0'
30
- - - ">="
31
- - !ruby/object:Gem::Version
32
- version: 1.0.5
33
- description: |2
34
- Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.
35
- Inspired by Erlang, Clojure, Go, JavaScript, actors, and classic concurrency patterns.
36
- email: jerry.dantonio@gmail.com
12
+ date: 2015-06-08 00:00:00.000000000 Z
13
+ dependencies: []
14
+ description: |
15
+ Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.
16
+ Inspired by Erlang, Clojure, Go, JavaScript, actors, and classic concurrency patterns.
17
+ email:
18
+ - jerry.dantonio@gmail.com
19
+ - concurrent-ruby@googlegroups.com
37
20
  executables: []
38
21
  extensions: []
39
22
  extra_rdoc_files:
@@ -45,51 +28,19 @@ files:
45
28
  - LICENSE.txt
46
29
  - README.md
47
30
  - lib/concurrent.rb
48
- - lib/concurrent/actor.rb
49
- - lib/concurrent/actor/behaviour.rb
50
- - lib/concurrent/actor/behaviour/abstract.rb
51
- - lib/concurrent/actor/behaviour/awaits.rb
52
- - lib/concurrent/actor/behaviour/buffer.rb
53
- - lib/concurrent/actor/behaviour/errors_on_unknown_message.rb
54
- - lib/concurrent/actor/behaviour/executes_context.rb
55
- - lib/concurrent/actor/behaviour/linking.rb
56
- - lib/concurrent/actor/behaviour/pausing.rb
57
- - lib/concurrent/actor/behaviour/removes_child.rb
58
- - lib/concurrent/actor/behaviour/sets_results.rb
59
- - lib/concurrent/actor/behaviour/supervised.rb
60
- - lib/concurrent/actor/behaviour/supervising.rb
61
- - lib/concurrent/actor/behaviour/terminates_children.rb
62
- - lib/concurrent/actor/behaviour/termination.rb
63
- - lib/concurrent/actor/context.rb
64
- - lib/concurrent/actor/core.rb
65
- - lib/concurrent/actor/default_dead_letter_handler.rb
66
- - lib/concurrent/actor/envelope.rb
67
- - lib/concurrent/actor/errors.rb
68
- - lib/concurrent/actor/internal_delegations.rb
69
- - lib/concurrent/actor/public_delegations.rb
70
- - lib/concurrent/actor/reference.rb
71
- - lib/concurrent/actor/root.rb
72
- - lib/concurrent/actor/type_check.rb
73
- - lib/concurrent/actor/utils.rb
74
- - lib/concurrent/actor/utils/ad_hoc.rb
75
- - lib/concurrent/actor/utils/balancer.rb
76
- - lib/concurrent/actor/utils/broadcast.rb
77
- - lib/concurrent/actor/utils/pool.rb
78
- - lib/concurrent/actress.rb
79
- - lib/concurrent/agent.rb
80
31
  - lib/concurrent/async.rb
81
- - lib/concurrent/atomic.rb
32
+ - lib/concurrent/atom.rb
82
33
  - lib/concurrent/atomic/atomic_boolean.rb
83
34
  - lib/concurrent/atomic/atomic_fixnum.rb
35
+ - lib/concurrent/atomic/atomic_reference.rb
84
36
  - lib/concurrent/atomic/condition.rb
85
- - lib/concurrent/atomic/copy_on_notify_observer_set.rb
86
- - lib/concurrent/atomic/copy_on_write_observer_set.rb
87
37
  - lib/concurrent/atomic/count_down_latch.rb
88
38
  - lib/concurrent/atomic/cyclic_barrier.rb
89
39
  - lib/concurrent/atomic/event.rb
40
+ - lib/concurrent/atomic/read_write_lock.rb
90
41
  - lib/concurrent/atomic/semaphore.rb
91
- - lib/concurrent/atomic/synchronization.rb
92
42
  - lib/concurrent/atomic/thread_local_var.rb
43
+ - lib/concurrent/atomic/thread_local_var/weak_key_map.rb
93
44
  - lib/concurrent/atomic_reference/concurrent_update_error.rb
94
45
  - lib/concurrent/atomic_reference/direct_update.rb
95
46
  - lib/concurrent/atomic_reference/jruby.rb
@@ -98,23 +49,23 @@ files:
98
49
  - lib/concurrent/atomic_reference/rbx.rb
99
50
  - lib/concurrent/atomic_reference/ruby.rb
100
51
  - lib/concurrent/atomics.rb
101
- - lib/concurrent/channel/buffered_channel.rb
102
- - lib/concurrent/channel/channel.rb
103
- - lib/concurrent/channel/unbuffered_channel.rb
104
- - lib/concurrent/channel/waitable_list.rb
105
- - lib/concurrent/channels.rb
106
- - lib/concurrent/collection/blocking_ring_buffer.rb
52
+ - lib/concurrent/collection/copy_on_notify_observer_set.rb
53
+ - lib/concurrent/collection/copy_on_write_observer_set.rb
107
54
  - lib/concurrent/collection/priority_queue.rb
108
- - lib/concurrent/collection/ring_buffer.rb
109
- - lib/concurrent/collections.rb
55
+ - lib/concurrent/concern/deprecation.rb
56
+ - lib/concurrent/concern/dereferenceable.rb
57
+ - lib/concurrent/concern/logging.rb
58
+ - lib/concurrent/concern/obligation.rb
59
+ - lib/concurrent/concern/observable.rb
110
60
  - lib/concurrent/configuration.rb
111
61
  - lib/concurrent/dataflow.rb
112
62
  - lib/concurrent/delay.rb
113
- - lib/concurrent/dereferenceable.rb
63
+ - lib/concurrent/edge.rb
114
64
  - lib/concurrent/errors.rb
115
65
  - lib/concurrent/exchanger.rb
116
66
  - lib/concurrent/executor/cached_thread_pool.rb
117
67
  - lib/concurrent/executor/executor.rb
68
+ - lib/concurrent/executor/executor_service.rb
118
69
  - lib/concurrent/executor/fixed_thread_pool.rb
119
70
  - lib/concurrent/executor/immediate_executor.rb
120
71
  - lib/concurrent/executor/indirect_immediate_executor.rb
@@ -122,37 +73,49 @@ files:
122
73
  - lib/concurrent/executor/java_fixed_thread_pool.rb
123
74
  - lib/concurrent/executor/java_single_thread_executor.rb
124
75
  - lib/concurrent/executor/java_thread_pool_executor.rb
125
- - lib/concurrent/executor/per_thread_executor.rb
126
76
  - lib/concurrent/executor/ruby_cached_thread_pool.rb
127
77
  - lib/concurrent/executor/ruby_fixed_thread_pool.rb
128
78
  - lib/concurrent/executor/ruby_single_thread_executor.rb
129
79
  - lib/concurrent/executor/ruby_thread_pool_executor.rb
130
- - lib/concurrent/executor/ruby_thread_pool_worker.rb
131
80
  - lib/concurrent/executor/safe_task_executor.rb
132
81
  - lib/concurrent/executor/serialized_execution.rb
82
+ - lib/concurrent/executor/simple_executor_service.rb
133
83
  - lib/concurrent/executor/single_thread_executor.rb
134
84
  - lib/concurrent/executor/thread_pool_executor.rb
135
85
  - lib/concurrent/executor/timer_set.rb
136
86
  - lib/concurrent/executors.rb
137
87
  - lib/concurrent/future.rb
88
+ - lib/concurrent/immutable_struct.rb
138
89
  - lib/concurrent/ivar.rb
139
90
  - lib/concurrent/lazy_register.rb
140
- - lib/concurrent/logging.rb
91
+ - lib/concurrent/maybe.rb
92
+ - lib/concurrent/mutable_struct.rb
141
93
  - lib/concurrent/mvar.rb
142
- - lib/concurrent/obligation.rb
143
- - lib/concurrent/observable.rb
144
- - lib/concurrent/options_parser.rb
145
94
  - lib/concurrent/promise.rb
146
95
  - lib/concurrent/scheduled_task.rb
96
+ - lib/concurrent/settable_struct.rb
97
+ - lib/concurrent/synchronization.rb
98
+ - lib/concurrent/synchronization/abstract_object.rb
99
+ - lib/concurrent/synchronization/abstract_struct.rb
100
+ - lib/concurrent/synchronization/condition.rb
101
+ - lib/concurrent/synchronization/java_object.rb
102
+ - lib/concurrent/synchronization/lock.rb
103
+ - lib/concurrent/synchronization/monitor_object.rb
104
+ - lib/concurrent/synchronization/mutex_object.rb
105
+ - lib/concurrent/synchronization/object.rb
106
+ - lib/concurrent/synchronization/rbx_object.rb
147
107
  - lib/concurrent/timer_task.rb
148
108
  - lib/concurrent/tvar.rb
149
109
  - lib/concurrent/utilities.rb
150
- - lib/concurrent/utility/processor_count.rb
110
+ - lib/concurrent/utility/at_exit.rb
111
+ - lib/concurrent/utility/engine.rb
112
+ - lib/concurrent/utility/monotonic_time.rb
113
+ - lib/concurrent/utility/native_extension_loader.rb
114
+ - lib/concurrent/utility/processor_counter.rb
151
115
  - lib/concurrent/utility/timeout.rb
152
116
  - lib/concurrent/utility/timer.rb
153
117
  - lib/concurrent/version.rb
154
118
  - lib/concurrent_ruby.rb
155
- - lib/extension_helper.rb
156
119
  homepage: http://www.concurrent-ruby.com
157
120
  licenses:
158
121
  - MIT
@@ -168,14 +131,15 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
131
  version: 1.9.3
169
132
  required_rubygems_version: !ruby/object:Gem::Requirement
170
133
  requirements:
171
- - - ">="
134
+ - - ">"
172
135
  - !ruby/object:Gem::Version
173
- version: '0'
136
+ version: 1.3.1
174
137
  requirements: []
175
138
  rubyforge_project:
176
- rubygems_version: 2.4.5
139
+ rubygems_version: 2.4.7
177
140
  signing_key:
178
141
  specification_version: 4
179
142
  summary: Modern concurrency tools for Ruby. Inspired by Erlang, Clojure, Scala, Haskell,
180
143
  F#, C#, Java, and classic concurrency patterns.
181
144
  test_files: []
145
+ has_rdoc:
@@ -1,103 +0,0 @@
1
- require 'concurrent/configuration'
2
- require 'concurrent/executor/serialized_execution'
3
- require 'concurrent/ivar'
4
- require 'concurrent/logging'
5
- require 'concurrent/atomic/synchronization'
6
-
7
- module Concurrent
8
- # TODO https://github.com/celluloid/celluloid/wiki/Supervision-Groups ?
9
- # TODO Remote actors using DRb
10
- # TODO IO interoperation
11
- # TODO un/become
12
-
13
- # TODO doc
14
- # - what happens if I try to supervise using a normal Context?
15
- # - how to change behaviours
16
- # - how to implement custom restarting?
17
- # - pool for io operations using different executor
18
- # - document guaranteed ordering
19
-
20
- # {include:file:doc/actor/main.md}
21
- module Actor
22
-
23
- require 'concurrent/actor/type_check'
24
- require 'concurrent/actor/errors'
25
- require 'concurrent/actor/public_delegations'
26
- require 'concurrent/actor/internal_delegations'
27
- require 'concurrent/actor/envelope'
28
- require 'concurrent/actor/reference'
29
- require 'concurrent/actor/core'
30
- require 'concurrent/actor/behaviour'
31
- require 'concurrent/actor/context'
32
-
33
- require 'concurrent/actor/default_dead_letter_handler'
34
- require 'concurrent/actor/root'
35
- require 'concurrent/actor/utils'
36
-
37
- # @return [Reference, nil] current executing actor if any
38
- def self.current
39
- Thread.current[:__current_actor__]
40
- end
41
-
42
- @root = Delay.new do
43
- Core.new(parent: nil, name: '/', class: Root, initialized: ivar = IVar.new).reference.tap do
44
- ivar.no_error!
45
- end
46
- end
47
-
48
- # A root actor, a default parent of all actors spawned outside an actor
49
- def self.root
50
- @root.value!
51
- end
52
-
53
- # Spawns a new actor.
54
- #
55
- # @example simple
56
- # Actor.spawn(AdHoc, :ping1) { -> message { message } }
57
- #
58
- # @example complex
59
- # Actor.spawn name: :ping3,
60
- # class: AdHoc,
61
- # args: [1]
62
- # executor: Concurrent.configuration.global_task_pool do |add|
63
- # lambda { |number| number + add }
64
- # end
65
- #
66
- # @param block for context_class instantiation
67
- # @param args see {.spawn_optionify}
68
- # @return [Reference] never the actual actor
69
- def self.spawn(*args, &block)
70
- if Actor.current
71
- Core.new(spawn_optionify(*args).merge(parent: Actor.current), &block).reference
72
- else
73
- root.ask([:spawn, spawn_optionify(*args), block]).value!
74
- end
75
- end
76
-
77
- # as {.spawn} but it'll raise when Actor not initialized properly
78
- def self.spawn!(*args, &block)
79
- spawn(spawn_optionify(*args).merge(initialized: ivar = IVar.new), &block).tap { ivar.no_error! }
80
- end
81
-
82
- # @overload spawn_optionify(context_class, name, *args)
83
- # @param [AbstractContext] context_class to be spawned
84
- # @param [String, Symbol] name of the instance, it's used to generate the {Core#path} of the actor
85
- # @param args for context_class instantiation
86
- # @overload spawn_optionify(opts)
87
- # see {Core#initialize} opts
88
- def self.spawn_optionify(*args)
89
- if args.size == 1 && args.first.is_a?(Hash)
90
- args.first
91
- else
92
- { class: args[0],
93
- name: args[1],
94
- args: args[2..-1] }
95
- end
96
- end
97
-
98
- # call this to disable experimental warning
99
- def self.i_know_it_is_experimental!
100
- warn 'Method Actor.i_know_it_is_experimental! is deprecated. The Actors are no longer experimental.'
101
- end
102
- end
103
- end
@@ -1,70 +0,0 @@
1
- module Concurrent
2
- module Actor
3
-
4
- # Actors have modular architecture, which is achieved by combining a light core with chain of
5
- # behaviours. Each message or internal event propagates through the chain allowing the
6
- # behaviours react based on their responsibility. listing few as an example:
7
- #
8
- # - {Behaviour::Linking}:
9
- #
10
- # > {include:Actor::Behaviour::Linking}
11
- #
12
- # - {Behaviour::Awaits}:
13
- #
14
- # > {include:Actor::Behaviour::Awaits}
15
- #
16
- # See {Behaviour}'s namespace fo other behaviours.
17
- # If needed new behaviours can be added, or old one removed to get required behaviour.
18
- module Behaviour
19
- MESSAGE_PROCESSED = Object.new
20
-
21
- require 'concurrent/actor/behaviour/abstract'
22
- require 'concurrent/actor/behaviour/awaits'
23
- require 'concurrent/actor/behaviour/buffer'
24
- require 'concurrent/actor/behaviour/errors_on_unknown_message'
25
- require 'concurrent/actor/behaviour/executes_context'
26
- require 'concurrent/actor/behaviour/linking'
27
- require 'concurrent/actor/behaviour/pausing'
28
- require 'concurrent/actor/behaviour/removes_child'
29
- require 'concurrent/actor/behaviour/sets_results'
30
- require 'concurrent/actor/behaviour/supervised'
31
- require 'concurrent/actor/behaviour/supervising'
32
- require 'concurrent/actor/behaviour/termination'
33
- require 'concurrent/actor/behaviour/terminates_children'
34
-
35
- def self.basic_behaviour_definition
36
- [*base,
37
- *user_messages(:terminate!)]
38
- end
39
-
40
- def self.restarting_behaviour_definition
41
- [*base,
42
- *supervised,
43
- [Behaviour::Supervising, [:reset!, :one_for_one]],
44
- *user_messages(:pause!)]
45
- end
46
-
47
- def self.base
48
- [[SetResults, [:terminate!]],
49
- # has to be before Termination to be able to remove children form terminated actor
50
- [RemovesChild, []],
51
- [Termination, []],
52
- [TerminatesChildren, []],
53
- [Linking, []]]
54
- end
55
-
56
- def self.supervised
57
- [[Supervised, []],
58
- [Pausing, []]]
59
- end
60
-
61
- def self.user_messages(on_error)
62
- [[Buffer, []],
63
- [SetResults, [on_error]],
64
- [Awaits, []],
65
- [ExecutesContext, []],
66
- [ErrorsOnUnknownMessage, []]]
67
- end
68
- end
69
- end
70
- end