concurrent-ruby 0.9.0.pre3 → 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +2 -3
- data/README.md +17 -10
- data/lib/concurrent/concern/deprecation.rb +10 -3
- data/lib/concurrent/concern/logging.rb +2 -0
- data/lib/concurrent/configuration.rb +50 -36
- data/lib/concurrent/scheduled_task.rb +41 -39
- data/lib/concurrent/synchronization/java_object.rb +0 -1
- data/lib/concurrent/synchronization/monitor_object.rb +2 -0
- data/lib/concurrent/utility/at_exit.rb +6 -6
- data/lib/concurrent/utility/engine.rb +4 -0
- data/lib/concurrent/version.rb +2 -2
- metadata +4 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 06e8ac2ad12cfbd2d70c6d8d687b2a9e338a9a31
|
4
|
+
data.tar.gz: 00438fa26d2bd287644b0dccd7b4a31a17e350cd
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c6f70cef24b30511a49b2e0b348b9b291bc5c53505babfb3665b35f816aec3877fbca1c5e84c5383c78be65c26ae6b99947ea94fcc9e1c88ffebcad6f8f7ec54
|
7
|
+
data.tar.gz: b23f9e760e1d7c079a1e467181d796b65366b6d068cbf797cbec1937f42e8919825f2515d25c23ea04de88750229698019b85c6dc0f204aa3419d3b720f339a8
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,4 @@
|
|
1
|
-
|
2
|
-
|
1
|
+
## Current Release v0.9.0 (10 July 2015)
|
3
2
|
|
4
3
|
* Updated `AtomicReference`
|
5
4
|
- `AtomicReference#try_update` now simply returns instead of raising exception
|
@@ -98,7 +97,7 @@
|
|
98
97
|
* Removed brute-force killing of threads in tests
|
99
98
|
* Fixed a thread pool bug when the operating system cannot allocate more threads
|
100
99
|
|
101
|
-
|
100
|
+
### Release v0.8.0 (25 January 2015)
|
102
101
|
|
103
102
|
* C extension for MRI have been extracted into the `concurrent-ruby-ext` companion gem.
|
104
103
|
Please see the README for more detail.
|
data/README.md
CHANGED
@@ -1,5 +1,5 @@
|
|
1
1
|
# Concurrent Ruby
|
2
|
-
[![Gem Version](https://badge.fury.io/rb/concurrent-ruby.svg)](http://badge.fury.io/rb/concurrent-ruby) [![Build Status](https://travis-ci.org/ruby-concurrency/concurrent-ruby.svg?branch=master)](https://travis-ci.org/ruby-concurrency/concurrent-ruby) [![Code Climate](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby.svg)](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby) [![Inline docs](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby.svg)](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby) [![Dependency Status](https://gemnasium.com/ruby-concurrency/concurrent-ruby.svg)](https://gemnasium.com/ruby-concurrency/concurrent-ruby) [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT) [![Gitter chat](http://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby)
|
2
|
+
[![Gem Version](https://badge.fury.io/rb/concurrent-ruby.svg)](http://badge.fury.io/rb/concurrent-ruby) [![Build Status](https://travis-ci.org/ruby-concurrency/concurrent-ruby.svg?branch=master)](https://travis-ci.org/ruby-concurrency/concurrent-ruby) [![Build status](https://ci.appveyor.com/api/projects/status/iq8aboyuu3etad4w?svg=true)](https://ci.appveyor.com/project/rubyconcurrency/concurrent-ruby) [![Code Climate](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby.svg)](https://codeclimate.com/github/ruby-concurrency/concurrent-ruby) [![Inline docs](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby.svg)](http://inch-ci.org/github/ruby-concurrency/concurrent-ruby) [![Dependency Status](https://gemnasium.com/ruby-concurrency/concurrent-ruby.svg)](https://gemnasium.com/ruby-concurrency/concurrent-ruby) [![License](https://img.shields.io/badge/license-MIT-green.svg)](http://opensource.org/licenses/MIT) [![Gitter chat](http://img.shields.io/badge/gitter-join%20chat%20%E2%86%92-brightgreen.svg)](https://gitter.im/ruby-concurrency/concurrent-ruby)
|
3
3
|
|
4
4
|
<table>
|
5
5
|
<tr>
|
@@ -39,6 +39,7 @@
|
|
39
39
|
|
40
40
|
MRI 1.9.3, 2.0, 2.1, 2.2, JRuby (1.9 mode), and Rubinius 2.x are supported.
|
41
41
|
This gem should be fully compatible with any interpreter that is compliant with Ruby 1.9.3 or newer.
|
42
|
+
Java 8 is required for JRuby (Java 7 support is deprecated in version 0.9 and will be removed in 1.0).
|
42
43
|
|
43
44
|
## Features & Documentation
|
44
45
|
|
@@ -127,14 +128,14 @@ be obeyed though. Features developed in `concurrent-ruby-edge` are expected to m
|
|
127
128
|
|
128
129
|
#### Statuses:
|
129
130
|
|
130
|
-
*Why
|
131
|
+
*Why are these not in core?*
|
131
132
|
|
132
|
-
- **Actor** -
|
133
|
-
- **Future/Promise Framework** - partial documentation and tests
|
134
|
-
- **Agent** -
|
135
|
-
- **Channel** -
|
136
|
-
- **Exchanger** -
|
137
|
-
- **LazyRegister** -
|
133
|
+
- **Actor** - Partial documentation and tests; stability is good.
|
134
|
+
- **Future/Promise Framework** - API changes; partial documentation and tests; stability good.
|
135
|
+
- **Agent** - Incomplete behaviour compared to Clojure's models; stability good.
|
136
|
+
- **Channel** - Missing documentation; limted features; stability good.
|
137
|
+
- **Exchanger** - Known race condition requiring a new implementation.
|
138
|
+
- **LazyRegister** - Missing documentation and tests.
|
138
139
|
|
139
140
|
## Usage
|
140
141
|
|
@@ -248,10 +249,16 @@ bundle exec rake build # Build JRuby-specific core gem (alias for `
|
|
248
249
|
bundle exec rake build:core # Build concurrent-ruby-<version>-java.gem into the pkg directory
|
249
250
|
|
250
251
|
*All except JRuby*
|
251
|
-
bundle exec rake build # Build core and extension gems
|
252
252
|
bundle exec rake build:core # Build concurrent-ruby-<version>.gem into the pkg directory
|
253
253
|
bundle exec rake build:ext # Build concurrent-ruby-ext-<version>.gem into the pkg directory
|
254
254
|
|
255
|
+
*When Docker IS installed*
|
256
|
+
bundle exec rake build:windows # Build the windows binary <version> gems per rake-compiler-dock
|
257
|
+
bundle exec rake build # Build core, extension, and edge gems, including Windows binaries
|
258
|
+
|
259
|
+
*When Docker is NOT installed*
|
260
|
+
bundle exec rake build # Build core, extension, and edge gems (excluding Windows binaries)
|
261
|
+
|
255
262
|
*All*
|
256
263
|
bundle exec rake clean # Remove any temporary products
|
257
264
|
bundle exec rake clobber # Remove any generated file
|
@@ -260,7 +267,7 @@ bundle exec rake compile # Compile all the extensions
|
|
260
267
|
|
261
268
|
## Maintainers
|
262
269
|
|
263
|
-
* [Jerry D'Antonio](https://github.com/jdantonio)
|
270
|
+
* [Jerry D'Antonio](https://github.com/jdantonio) (creator)
|
264
271
|
* [Michele Della Torre](https://github.com/mighe)
|
265
272
|
* [Chris Seaton](https://github.com/chrisseaton)
|
266
273
|
* [Lucas Allan](https://github.com/lucasallan)
|
@@ -10,18 +10,25 @@ module Concurrent
|
|
10
10
|
include Concern::Logging
|
11
11
|
|
12
12
|
def deprecated(message, strip = 2)
|
13
|
-
caller_line = caller(strip).first
|
14
|
-
klass = if
|
13
|
+
caller_line = caller(strip).first if strip > 0
|
14
|
+
klass = if Module === self
|
15
15
|
self
|
16
16
|
else
|
17
17
|
self.class
|
18
18
|
end
|
19
|
-
|
19
|
+
message = if strip > 0
|
20
|
+
format("[DEPRECATED] %s\ncalled on: %s", message, caller_line)
|
21
|
+
else
|
22
|
+
format('[DEPRECATED] %s', message)
|
23
|
+
end
|
24
|
+
log WARN, klass.to_s, message
|
20
25
|
end
|
21
26
|
|
22
27
|
def deprecated_method(old_name, new_name)
|
23
28
|
deprecated "`#{old_name}` is deprecated and it'll removed in next release, use `#{new_name}` instead", 3
|
24
29
|
end
|
30
|
+
|
31
|
+
extend self
|
25
32
|
end
|
26
33
|
end
|
27
34
|
end
|
@@ -15,6 +15,8 @@ module Concurrent
|
|
15
15
|
# @param [String, nil] message when nil block is used to generate the message
|
16
16
|
# @yieldreturn [String] a message
|
17
17
|
def log(level, progname, message = nil, &block)
|
18
|
+
#NOTE: Cannot require 'concurrent/configuration' above due to circular references.
|
19
|
+
# Assume that the gem has been initialized if we've gotten this far.
|
18
20
|
(@logger || Concurrent.global_logger).call level, progname, message, &block
|
19
21
|
rescue => error
|
20
22
|
$stderr.puts "`Concurrent.configuration.logger` failed to log #{[level, progname, message, block]}\n" +
|
@@ -11,37 +11,6 @@ module Concurrent
|
|
11
11
|
extend Concern::Logging
|
12
12
|
extend Concern::Deprecation
|
13
13
|
|
14
|
-
# Suppresses all output when used for logging.
|
15
|
-
NULL_LOGGER = lambda { |level, progname, message = nil, &block| }
|
16
|
-
|
17
|
-
# @!visibility private
|
18
|
-
GLOBAL_LOGGER = AtomicReference.new(NULL_LOGGER)
|
19
|
-
private_constant :GLOBAL_LOGGER
|
20
|
-
|
21
|
-
# @!visibility private
|
22
|
-
GLOBAL_FAST_EXECUTOR = Delay.new { Concurrent.new_fast_executor(auto_terminate: true) }
|
23
|
-
private_constant :GLOBAL_FAST_EXECUTOR
|
24
|
-
|
25
|
-
# @!visibility private
|
26
|
-
GLOBAL_IO_EXECUTOR = Delay.new { Concurrent.new_io_executor(auto_terminate: true) }
|
27
|
-
private_constant :GLOBAL_IO_EXECUTOR
|
28
|
-
|
29
|
-
# @!visibility private
|
30
|
-
GLOBAL_TIMER_SET = Delay.new { TimerSet.new(auto_terminate: true) }
|
31
|
-
private_constant :GLOBAL_TIMER_SET
|
32
|
-
|
33
|
-
# @!visibility private
|
34
|
-
GLOBAL_IMMEDIATE_EXECUTOR = ImmediateExecutor.new
|
35
|
-
private_constant :GLOBAL_IMMEDIATE_EXECUTOR
|
36
|
-
|
37
|
-
def self.global_logger
|
38
|
-
GLOBAL_LOGGER.value
|
39
|
-
end
|
40
|
-
|
41
|
-
def self.global_logger=(value)
|
42
|
-
GLOBAL_LOGGER.value = value
|
43
|
-
end
|
44
|
-
|
45
14
|
# @return [Logger] Logger with provided level and output.
|
46
15
|
def self.create_stdlib_logger(level = Logger::FATAL, output = $stderr)
|
47
16
|
logger = Logger.new(output)
|
@@ -62,17 +31,48 @@ module Concurrent
|
|
62
31
|
progname,
|
63
32
|
formatted_message
|
64
33
|
end
|
65
|
-
|
34
|
+
|
35
|
+
lambda do |level, progname, message = nil, &block|
|
36
|
+
logger.add level, message, progname, &block
|
37
|
+
end
|
66
38
|
end
|
67
39
|
|
68
40
|
# Use logger created by #create_stdlib_logger to log concurrent-ruby messages.
|
69
41
|
def self.use_stdlib_logger(level = Logger::FATAL, output = $stderr)
|
70
|
-
|
71
|
-
Concurrent.global_logger = lambda do |level, progname, message = nil, &block|
|
72
|
-
logger.add level, message, progname, &block
|
73
|
-
end
|
42
|
+
Concurrent.global_logger = create_stdlib_logger level, output
|
74
43
|
end
|
75
44
|
|
45
|
+
# Suppresses all output when used for logging.
|
46
|
+
NULL_LOGGER = lambda { |level, progname, message = nil, &block| }
|
47
|
+
|
48
|
+
# @!visibility private
|
49
|
+
GLOBAL_LOGGER = AtomicReference.new(create_stdlib_logger(Logger::WARN))
|
50
|
+
private_constant :GLOBAL_LOGGER
|
51
|
+
|
52
|
+
def self.global_logger
|
53
|
+
GLOBAL_LOGGER.value
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.global_logger=(value)
|
57
|
+
GLOBAL_LOGGER.value = value
|
58
|
+
end
|
59
|
+
|
60
|
+
# @!visibility private
|
61
|
+
GLOBAL_FAST_EXECUTOR = Delay.new { Concurrent.new_fast_executor(auto_terminate: true) }
|
62
|
+
private_constant :GLOBAL_FAST_EXECUTOR
|
63
|
+
|
64
|
+
# @!visibility private
|
65
|
+
GLOBAL_IO_EXECUTOR = Delay.new { Concurrent.new_io_executor(auto_terminate: true) }
|
66
|
+
private_constant :GLOBAL_IO_EXECUTOR
|
67
|
+
|
68
|
+
# @!visibility private
|
69
|
+
GLOBAL_TIMER_SET = Delay.new { TimerSet.new(auto_terminate: true) }
|
70
|
+
private_constant :GLOBAL_TIMER_SET
|
71
|
+
|
72
|
+
# @!visibility private
|
73
|
+
GLOBAL_IMMEDIATE_EXECUTOR = ImmediateExecutor.new
|
74
|
+
private_constant :GLOBAL_IMMEDIATE_EXECUTOR
|
75
|
+
|
76
76
|
# Disables AtExit handlers including pool auto-termination handlers.
|
77
77
|
# When disabled it will be the application programmer's responsibility
|
78
78
|
# to ensure that the handlers are shutdown properly prior to application
|
@@ -275,4 +275,18 @@ module Concurrent
|
|
275
275
|
def self.configure
|
276
276
|
yield(configuration)
|
277
277
|
end
|
278
|
+
|
279
|
+
# for dependency reasons this check cannot be in concurrent/synchronization
|
280
|
+
if Concurrent.on_jruby?
|
281
|
+
require 'java'
|
282
|
+
|
283
|
+
version_string = java.lang.System.getProperties['java.runtime.version']
|
284
|
+
version = version_string.split('.', 3)[0..1].map(&:to_i)
|
285
|
+
if (version <=> [1, 8]) < 0
|
286
|
+
deprecated <<-TXT.gsub(/^\s*\|/, '').chop, 0
|
287
|
+
|Java 7 is deprecated, please use Java 8.
|
288
|
+
|Java 7 support is only best effort, it may not work. It will be removed in next release (1.0).
|
289
|
+
TXT
|
290
|
+
end
|
291
|
+
end
|
278
292
|
end
|
@@ -5,52 +5,54 @@ require 'concurrent/collection/copy_on_notify_observer_set'
|
|
5
5
|
require 'concurrent/executor/executor'
|
6
6
|
require 'concurrent/executor/timer_set'
|
7
7
|
require 'concurrent/utility/monotonic_time'
|
8
|
+
require 'concurrent/concern/deprecation'
|
8
9
|
|
9
10
|
module Concurrent
|
11
|
+
include Concern::Deprecation
|
10
12
|
|
11
13
|
# `ScheduledTask` is a close relative of `Concurrent::Future` but with one
|
12
14
|
# important difference: A `Future` is set to execute as soon as possible
|
13
15
|
# whereas a `ScheduledTask` is set to execute after a specified delay. This
|
14
16
|
# implementation is loosely based on Java's
|
15
|
-
# [ScheduledExecutorService](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html).
|
17
|
+
# [ScheduledExecutorService](http://docs.oracle.com/javase/7/docs/api/java/util/concurrent/ScheduledExecutorService.html).
|
16
18
|
# It is a more feature-rich variant of {Concurrent.timer}.
|
17
|
-
#
|
19
|
+
#
|
18
20
|
# The *intended* schedule time of task execution is set on object construction
|
19
21
|
# with the `delay` argument. The delay is a numeric (floating point or integer)
|
20
22
|
# representing a number of seconds in the future. Any other value or a numeric
|
21
23
|
# equal to or less than zero will result in an exception. The *actual* schedule
|
22
24
|
# time of task execution is set when the `execute` method is called.
|
23
|
-
#
|
25
|
+
#
|
24
26
|
# The constructor can also be given zero or more processing options. Currently
|
25
27
|
# the only supported options are those recognized by the
|
26
|
-
# [Dereferenceable](Dereferenceable) module.
|
27
|
-
#
|
28
|
+
# [Dereferenceable](Dereferenceable) module.
|
29
|
+
#
|
28
30
|
# The final constructor argument is a block representing the task to be performed.
|
29
31
|
# If no block is given an `ArgumentError` will be raised.
|
30
|
-
#
|
32
|
+
#
|
31
33
|
# **States**
|
32
|
-
#
|
34
|
+
#
|
33
35
|
# `ScheduledTask` mixes in the [Obligation](Obligation) module thus giving it
|
34
36
|
# "future" behavior. This includes the expected lifecycle states. `ScheduledTask`
|
35
37
|
# has one additional state, however. While the task (block) is being executed the
|
36
38
|
# state of the object will be `:processing`. This additional state is necessary
|
37
|
-
# because it has implications for task cancellation.
|
38
|
-
#
|
39
|
+
# because it has implications for task cancellation.
|
40
|
+
#
|
39
41
|
# **Cancellation**
|
40
|
-
#
|
42
|
+
#
|
41
43
|
# A `:pending` task can be cancelled using the `#cancel` method. A task in any
|
42
44
|
# other state, including `:processing`, cannot be cancelled. The `#cancel`
|
43
45
|
# method returns a boolean indicating the success of the cancellation attempt.
|
44
|
-
# A cancelled `ScheduledTask` cannot be restarted. It is immutable.
|
45
|
-
#
|
46
|
+
# A cancelled `ScheduledTask` cannot be restarted. It is immutable.
|
47
|
+
#
|
46
48
|
# **Obligation and Observation**
|
47
|
-
#
|
49
|
+
#
|
48
50
|
# The result of a `ScheduledTask` can be obtained either synchronously or
|
49
51
|
# asynchronously. `ScheduledTask` mixes in both the [Obligation](Obligation)
|
50
52
|
# module and the
|
51
53
|
# [Observable](http://ruby-doc.org/stdlib-2.0/libdoc/observer/rdoc/Observable.html)
|
52
54
|
# module from the Ruby standard library. With one exception `ScheduledTask`
|
53
|
-
# behaves identically to [Future](Observable) with regard to these modules.
|
55
|
+
# behaves identically to [Future](Observable) with regard to these modules.
|
54
56
|
#
|
55
57
|
# @!macro copy_options
|
56
58
|
#
|
@@ -59,7 +61,7 @@ module Concurrent
|
|
59
61
|
# require 'concurrent'
|
60
62
|
# require 'thread' # for Queue
|
61
63
|
# require 'open-uri' # for open(uri)
|
62
|
-
#
|
64
|
+
#
|
63
65
|
# class Ticker
|
64
66
|
# def get_year_end_closing(symbol, year)
|
65
67
|
# uri = "http://ichart.finance.yahoo.com/table.csv?s=#{symbol}&a=11&b=01&c=#{year}&d=11&e=31&f=#{year}&g=m"
|
@@ -67,75 +69,75 @@ module Concurrent
|
|
67
69
|
# data[1].split(',')[4].to_f
|
68
70
|
# end
|
69
71
|
# end
|
70
|
-
#
|
72
|
+
#
|
71
73
|
# # Future
|
72
74
|
# price = Concurrent::Future.execute{ Ticker.new.get_year_end_closing('TWTR', 2013) }
|
73
75
|
# price.state #=> :pending
|
74
76
|
# sleep(1) # do other stuff
|
75
77
|
# price.value #=> 63.65
|
76
78
|
# price.state #=> :fulfilled
|
77
|
-
#
|
79
|
+
#
|
78
80
|
# # ScheduledTask
|
79
81
|
# task = Concurrent::ScheduledTask.execute(2){ Ticker.new.get_year_end_closing('INTC', 2013) }
|
80
82
|
# task.state #=> :pending
|
81
83
|
# sleep(3) # do other stuff
|
82
84
|
# task.value #=> 25.96
|
83
|
-
#
|
85
|
+
#
|
84
86
|
# @example Successful task execution
|
85
|
-
#
|
87
|
+
#
|
86
88
|
# task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }
|
87
89
|
# task.state #=> :unscheduled
|
88
90
|
# task.execute
|
89
91
|
# task.state #=> pending
|
90
|
-
#
|
92
|
+
#
|
91
93
|
# # wait for it...
|
92
94
|
# sleep(3)
|
93
|
-
#
|
95
|
+
#
|
94
96
|
# task.unscheduled? #=> false
|
95
97
|
# task.pending? #=> false
|
96
98
|
# task.fulfilled? #=> true
|
97
99
|
# task.rejected? #=> false
|
98
100
|
# task.value #=> 'What does the fox say?'
|
99
|
-
#
|
101
|
+
#
|
100
102
|
# @example One line creation and execution
|
101
|
-
#
|
103
|
+
#
|
102
104
|
# task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }.execute
|
103
105
|
# task.state #=> pending
|
104
|
-
#
|
106
|
+
#
|
105
107
|
# task = Concurrent::ScheduledTask.execute(2){ 'What do you get when you multiply 6 by 9?' }
|
106
108
|
# task.state #=> pending
|
107
|
-
#
|
109
|
+
#
|
108
110
|
# @example Failed task execution
|
109
|
-
#
|
111
|
+
#
|
110
112
|
# task = Concurrent::ScheduledTask.execute(2){ raise StandardError.new('Call me maybe?') }
|
111
113
|
# task.pending? #=> true
|
112
|
-
#
|
114
|
+
#
|
113
115
|
# # wait for it...
|
114
116
|
# sleep(3)
|
115
|
-
#
|
117
|
+
#
|
116
118
|
# task.unscheduled? #=> false
|
117
119
|
# task.pending? #=> false
|
118
120
|
# task.fulfilled? #=> false
|
119
121
|
# task.rejected? #=> true
|
120
122
|
# task.value #=> nil
|
121
|
-
# task.reason #=> #<StandardError: Call me maybe?>
|
122
|
-
#
|
123
|
+
# task.reason #=> #<StandardError: Call me maybe?>
|
124
|
+
#
|
123
125
|
# @example Task execution with observation
|
124
|
-
#
|
126
|
+
#
|
125
127
|
# observer = Class.new{
|
126
128
|
# def update(time, value, reason)
|
127
129
|
# puts "The task completed at #{time} with value '#{value}'"
|
128
130
|
# end
|
129
131
|
# }.new
|
130
|
-
#
|
132
|
+
#
|
131
133
|
# task = Concurrent::ScheduledTask.new(2){ 'What does the fox say?' }
|
132
134
|
# task.add_observer(observer)
|
133
135
|
# task.execute
|
134
136
|
# task.pending? #=> true
|
135
|
-
#
|
137
|
+
#
|
136
138
|
# # wait for it...
|
137
139
|
# sleep(3)
|
138
|
-
#
|
140
|
+
#
|
139
141
|
# #>> The task completed at 2013-11-07 12:26:09 -0500 with value 'What does the fox say?'
|
140
142
|
#
|
141
143
|
# @!macro monotonic_clock_warning
|
@@ -196,12 +198,12 @@ module Concurrent
|
|
196
198
|
#
|
197
199
|
# @deprecated use {#initial_delay} instead
|
198
200
|
def delay
|
199
|
-
|
201
|
+
deprecated_method 'delay', 'initial_delay'
|
200
202
|
initial_delay
|
201
203
|
end
|
202
204
|
|
203
205
|
# The monotonic time at which the the task is scheduled to be executed.
|
204
|
-
#
|
206
|
+
#
|
205
207
|
# @return [Float] the schedule time or nil if `unscheduled`
|
206
208
|
def schedule_time
|
207
209
|
synchronize { @time }
|
@@ -234,7 +236,7 @@ module Concurrent
|
|
234
236
|
#
|
235
237
|
# @deprecated Use {#processing?} instead.
|
236
238
|
def in_progress?
|
237
|
-
|
239
|
+
deprecated_method 'in_progress?', 'processing?'
|
238
240
|
processing?
|
239
241
|
end
|
240
242
|
|
@@ -260,7 +262,7 @@ module Concurrent
|
|
260
262
|
#
|
261
263
|
# @deprecated Use {#cancel} instead.
|
262
264
|
def stop
|
263
|
-
|
265
|
+
deprecated_method 'stop', 'cancel'
|
264
266
|
cancel
|
265
267
|
end
|
266
268
|
|
@@ -363,7 +365,7 @@ module Concurrent
|
|
363
365
|
# @!visibility private
|
364
366
|
def calculate_delay!(delay)
|
365
367
|
if delay.is_a?(Time)
|
366
|
-
|
368
|
+
deprecated 'Use an interval not a clock time; schedule is now based on a monotonic clock'
|
367
369
|
now = Time.now
|
368
370
|
raise ArgumentError.new('schedule time must be in the future') if delay <= now
|
369
371
|
delay.to_f - now.to_f
|
@@ -1,4 +1,4 @@
|
|
1
|
-
require '
|
1
|
+
require 'logger'
|
2
2
|
require 'concurrent/synchronization'
|
3
3
|
|
4
4
|
module Concurrent
|
@@ -8,7 +8,7 @@ module Concurrent
|
|
8
8
|
#
|
9
9
|
# @!visibility private
|
10
10
|
class AtExitImplementation < Synchronization::Object
|
11
|
-
include
|
11
|
+
include Logger::Severity
|
12
12
|
|
13
13
|
def initialize(*args)
|
14
14
|
super()
|
@@ -46,9 +46,9 @@ module Concurrent
|
|
46
46
|
def install
|
47
47
|
synchronize do
|
48
48
|
@installed ||= begin
|
49
|
-
|
50
|
-
|
51
|
-
|
49
|
+
at_exit { runner }
|
50
|
+
true
|
51
|
+
end
|
52
52
|
self
|
53
53
|
end
|
54
54
|
end
|
@@ -71,7 +71,7 @@ module Concurrent
|
|
71
71
|
begin
|
72
72
|
handler.call
|
73
73
|
rescue => error
|
74
|
-
|
74
|
+
Concurrent.global_logger.call(ERROR, error)
|
75
75
|
end
|
76
76
|
end
|
77
77
|
handlers.keys
|
data/lib/concurrent/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: concurrent-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.9.0
|
4
|
+
version: 0.9.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jerry D'Antonio
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-07-10 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: |
|
15
15
|
Modern concurrency tools including agents, futures, promises, thread pools, actors, supervisors, and more.
|
@@ -127,9 +127,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
127
127
|
version: 1.9.3
|
128
128
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
129
129
|
requirements:
|
130
|
-
- - "
|
130
|
+
- - ">="
|
131
131
|
- !ruby/object:Gem::Version
|
132
|
-
version:
|
132
|
+
version: '0'
|
133
133
|
requirements: []
|
134
134
|
rubyforge_project:
|
135
135
|
rubygems_version: 2.4.8
|