concurrent-ruby 0.8.0.pre2 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f7918a0f32c1369463e3045101a1a3b1629d501a
4
- data.tar.gz: c97009756916b18836a277c4d62df2f57c02b797
3
+ metadata.gz: c1cb9ee067ce09d0d58e0dbf2b704e9f05f3f23c
4
+ data.tar.gz: f70953ed219fd7da3f2011f426ed889e0293e65f
5
5
  SHA512:
6
- metadata.gz: 48a95b84f0d4f4545e0e962031d74e608ac922d7f99177fb98186ba3d6a4bc86e7f49033dae64afccdbb3c7a4730544826f91a362300548eb0519d145150fbbd
7
- data.tar.gz: 4624b6a91696efe3d365091171f6e03c9de2a764d8d1791892d0ae43293a05e08d740536914f9ef57b3e10f7f8ba1ee766f1e0bda322f24e53a2565038d47af0
6
+ metadata.gz: 23d3c454c1a17957ddb8c51320ca9ea0f365e8fb2e828b5a27e2db18d42d144679047198fcdb0dc5393349cfbfa84ba801baf5474b009634739a25e8585fb8d8
7
+ data.tar.gz: 45ba36f7d1aaba1dd7e5fc7a10a6922a5327c8f975bd4f5cabb2162b2b76b293884688f9bb8cbcfe8b23d61bb8cd4fd7b504b80360a3c28e204935169a67d167
@@ -1,4 +1,11 @@
1
- ### Next Release v0.7.2 (TBD)
1
+ ### Next Release v0.8.0 (25 January 2015)
2
+
3
+ * C extension for MRI have been extracted into the `concurrent-ruby-ext` companion gem.
4
+ Please see the README for more detail.
5
+ * Better variable isolation in `Promise` and `Future` via an `:args` option
6
+ * Continued to update intermittently failing tests
7
+
8
+ ## Current Release v0.7.2 (24 January 2015)
2
9
 
3
10
  * New `Semaphore` class based on [java.util.concurrent.Semaphore](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/Semaphore.html)
4
11
  * New `Promise.all?` and `Promise.any?` class methods
@@ -6,11 +13,16 @@
6
13
  * Thread pools still accept the `:overflow_policy` option but display a warning
7
14
  * Thread pools now implement `fallback_policy` behavior when not running (rather than universally rejecting tasks)
8
15
  * Fixed minor `set_deref_options` constructor bug in `Promise` class
16
+ * Fixed minor `require` bug in `ThreadLocalVar` class
17
+ * Fixed race condition bug in `TimerSet` class
18
+ * Fixed race condition bug in `TimerSet` class
19
+ * Fixed signal bug in `TimerSet#post` method
9
20
  * Numerous non-functional updates to clear warning when running in debug mode
10
21
  * Fixed more intermittently failing tests
11
22
  * Tests now run on new Travis build environment
23
+ * Multiple documentation updates
12
24
 
13
- ## Current Release v0.7.1 (4 December 2014)
25
+ ### Release v0.7.1 (4 December 2014)
14
26
 
15
27
  Please see the [roadmap](https://github.com/ruby-concurrency/concurrent-ruby/issues/142) for more information on the next planned release.
16
28
 
@@ -23,6 +23,8 @@ module Concurrent
23
23
  # global task pool (for short-running tasks)
24
24
  # @option opts [object] :executor when provided will run all operations on
25
25
  # this executor rather than the global thread pool (overrides :operation)
26
+ # @option opts [object, Array] :args zero or more arguments to be passed the task block on execution
27
+ #
26
28
  # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
27
29
  # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
28
30
  # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
@@ -35,6 +37,7 @@ module Concurrent
35
37
  @state = :unscheduled
36
38
  @task = block
37
39
  @executor = OptionsParser::get_executor_from(opts) || Concurrent.configuration.global_operation_pool
40
+ @args = OptionsParser::get_arguments_from(opts)
38
41
  end
39
42
 
40
43
  # Execute an `:unscheduled` `Future`. Immediately sets the state to `:pending` and
@@ -52,11 +55,9 @@ module Concurrent
52
55
  # @example Instance and execute in one line
53
56
  # future = Concurrent::Future.new{ sleep(1); 42 }.execute
54
57
  # future.state #=> :pending
55
- #
56
- # @since 0.5.0
57
58
  def execute
58
59
  if compare_and_set_state(:pending, :unscheduled)
59
- @executor.post{ work }
60
+ @executor.post(@args){ work }
60
61
  self
61
62
  end
62
63
  end
@@ -72,6 +73,8 @@ module Concurrent
72
73
  # global task pool (for short-running tasks)
73
74
  # @option opts [object] :executor when provided will run all operations on
74
75
  # this executor rather than the global thread pool (overrides :operation)
76
+ # @option opts [object, Array] :args zero or more arguments to be passed the task block on execution
77
+ #
75
78
  # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
76
79
  # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
77
80
  # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
@@ -84,8 +87,6 @@ module Concurrent
84
87
  # @example
85
88
  # future = Concurrent::Future.execute{ sleep(1); 42 }
86
89
  # future.state #=> :pending
87
- #
88
- # @since 0.5.0
89
90
  def self.execute(opts = {}, &block)
90
91
  Future.new(opts, &block).execute
91
92
  end
@@ -96,7 +97,7 @@ module Concurrent
96
97
 
97
98
  # @!visibility private
98
99
  def work # :nodoc:
99
- success, val, reason = SafeTaskExecutor.new(@task).execute
100
+ success, val, reason = SafeTaskExecutor.new(@task).execute(*@args)
100
101
  complete(success, val, reason)
101
102
  end
102
103
  end
@@ -23,6 +23,10 @@ module Concurrent
23
23
  end
24
24
  end
25
25
 
26
+ def get_arguments_from(opts = {})
27
+ [*opts.fetch(:args, [])]
28
+ end
29
+
26
30
  # Get the requested `Executor` based on the values set in the options hash.
27
31
  #
28
32
  # @param [Hash] opts the options defining the requested executor
@@ -172,22 +172,25 @@ module Concurrent
172
172
 
173
173
  # Initialize a new Promise with the provided options.
174
174
  #
175
- # @param [Hash] opts the options used to define the behavior at update and deref
175
+ # @!macro [attach] promise_init_options
176
176
  #
177
- # @option opts [Promise] :parent the parent `Promise` when building a chain/tree
178
- # @option opts [Proc] :on_fulfill fulfillment handler
179
- # @option opts [Proc] :on_reject rejection handler
177
+ # @param [Hash] opts the options used to define the behavior at update and deref
180
178
  #
181
- # @option opts [Boolean] :operation (false) when `true` will execute the future on the global
182
- # operation pool (for long-running operations), when `false` will execute the future on the
183
- # global task pool (for short-running tasks)
184
- # @option opts [object] :executor when provided will run all operations on
185
- # this executor rather than the global thread pool (overrides :operation)
179
+ # @option opts [Promise] :parent the parent `Promise` when building a chain/tree
180
+ # @option opts [Proc] :on_fulfill fulfillment handler
181
+ # @option opts [Proc] :on_reject rejection handler
186
182
  #
187
- # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
188
- # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
189
- # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
190
- # returning the value returned from the proc
183
+ # @option opts [Boolean] :operation (false) when `true` will execute the future on the global
184
+ # operation pool (for long-running operations), when `false` will execute the future on the
185
+ # global task pool (for short-running tasks)
186
+ # @option opts [object] :executor when provided will run all operations on
187
+ # this executor rather than the global thread pool (overrides :operation)
188
+ # @option opts [object, Array] :args zero or more arguments to be passed the task block on execution
189
+ #
190
+ # @option opts [String] :dup_on_deref (false) call `#dup` before returning the data
191
+ # @option opts [String] :freeze_on_deref (false) call `#freeze` before returning the data
192
+ # @option opts [String] :copy_on_deref (nil) call the given `Proc` passing the internal value and
193
+ # returning the value returned from the proc
191
194
  #
192
195
  # @see http://wiki.commonjs.org/wiki/Promises/A
193
196
  # @see http://promises-aplus.github.io/promises-spec/
@@ -195,6 +198,8 @@ module Concurrent
195
198
  opts.delete_if { |k, v| v.nil? }
196
199
 
197
200
  @executor = OptionsParser::get_executor_from(opts) || Concurrent.configuration.global_operation_pool
201
+ @args = OptionsParser::get_arguments_from(opts)
202
+
198
203
  @parent = opts.fetch(:parent) { nil }
199
204
  @on_fulfill = opts.fetch(:on_fulfill) { Proc.new { |result| result } }
200
205
  @on_reject = opts.fetch(:on_reject) { Proc.new { |reason| raise reason } }
@@ -219,7 +224,6 @@ module Concurrent
219
224
  end
220
225
 
221
226
  # @return [Promise]
222
- # @since 0.5.0
223
227
  def execute
224
228
  if root?
225
229
  if compare_and_set_state(:pending, :unscheduled)
@@ -232,7 +236,18 @@ module Concurrent
232
236
  self
233
237
  end
234
238
 
235
- # @since 0.5.0
239
+ # Create a new `Promise` object with the given block, execute it, and return the
240
+ # `:pending` object.
241
+ #
242
+ # @!macro promise_init_options
243
+ #
244
+ # @return [Promise] the newly created `Promise` in the `:pending` state
245
+ #
246
+ # @raise [ArgumentError] if no block is given
247
+ #
248
+ # @example
249
+ # promise = Concurrent::Promise.execute{ sleep(1); 42 }
250
+ # promise.state #=> :pending
236
251
  def self.execute(opts = {}, &block)
237
252
  new(opts, &block).execute
238
253
  end
@@ -389,6 +404,7 @@ module Concurrent
389
404
  composite
390
405
  end
391
406
 
407
+ # @!visibility private
392
408
  def set_pending
393
409
  mutex.synchronize do
394
410
  @state = :pending
@@ -413,6 +429,7 @@ module Concurrent
413
429
  nil
414
430
  end
415
431
 
432
+ # @!visibility private
416
433
  def notify_child(child)
417
434
  if_state(:fulfilled) { child.on_fulfill(apply_deref_options(@value)) }
418
435
  if_state(:rejected) { child.on_reject(@reason) }
@@ -421,7 +438,7 @@ module Concurrent
421
438
  # @!visibility private
422
439
  def realize(task)
423
440
  @executor.post do
424
- success, value, reason = SafeTaskExecutor.new(task).execute
441
+ success, value, reason = SafeTaskExecutor.new(task).execute(*@args)
425
442
 
426
443
  children_to_notify = mutex.synchronize do
427
444
  set_state!(success, value, reason)
@@ -432,11 +449,13 @@ module Concurrent
432
449
  end
433
450
  end
434
451
 
452
+ # @!visibility private
435
453
  def set_state!(success, value, reason)
436
454
  set_state(success, value, reason)
437
455
  event.set
438
456
  end
439
457
 
458
+ # @!visibility private
440
459
  def synchronized_set_state!(success, value, reason)
441
460
  mutex.lock
442
461
  set_state!(success, value, reason)
@@ -1,3 +1,3 @@
1
1
  module Concurrent
2
- VERSION = '0.8.0.pre2'
2
+ VERSION = '0.8.0'
3
3
  end
@@ -20,7 +20,7 @@ module Concurrent
20
20
  rescue LoadError
21
21
  # may be a Windows cross-compiled native gem
22
22
  begin
23
- require "#{RUBY_VERSION[0..2]}/concurrent/extension"
23
+ require "concurrent/#{RUBY_VERSION[0..2]}/extension"
24
24
  @@c_ext_loaded = true
25
25
  rescue LoadError
26
26
  warn 'Performance on MRI may be improved with the concurrent-ruby-ext gem. Please see http://concurrent-ruby.com'
@@ -31,7 +31,7 @@ module Concurrent
31
31
  require 'concurrent_ruby_ext'
32
32
  @@java_ext_loaded = true
33
33
  rescue LoadError
34
- warn 'Attempted to load Java extensions on unsupported platform. Continuing with pure-Ruby.'
34
+ warn 'Performance on JRuby may be improved by installing the pre-compiled Java extensions. Please see http://concurrent-ruby.com'
35
35
  end
36
36
  end
37
37
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: concurrent-ruby
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.8.0.pre2
4
+ version: 0.8.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jerry D'Antonio
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-15 00:00:00.000000000 Z
11
+ date: 2015-01-25 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: ref
@@ -168,9 +168,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
168
168
  version: 1.9.3
169
169
  required_rubygems_version: !ruby/object:Gem::Requirement
170
170
  requirements:
171
- - - ">"
171
+ - - ">="
172
172
  - !ruby/object:Gem::Version
173
- version: 1.3.1
173
+ version: '0'
174
174
  requirements: []
175
175
  rubyforge_project:
176
176
  rubygems_version: 2.4.5