concurrent-ruby 0.6.1 → 0.7.0.rc0
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.
- checksums.yaml +4 -4
- data/README.md +1 -1
- data/lib/concurrent.rb +3 -4
- data/lib/concurrent/atomic.rb +46 -0
- data/lib/concurrent/atomic_reference/concurrent_update_error.rb +7 -0
- data/lib/concurrent/atomic_reference/delegated_update.rb +28 -0
- data/lib/concurrent/atomic_reference/direct_update.rb +28 -0
- data/lib/concurrent/atomic_reference/jruby.rb +8 -0
- data/lib/concurrent/atomic_reference/mutex_atomic.rb +47 -0
- data/lib/concurrent/atomic_reference/numeric_cas_wrapper.rb +24 -0
- data/lib/concurrent/atomic_reference/rbx.rb +16 -0
- data/lib/concurrent/atomic_reference/ruby.rb +16 -0
- data/lib/concurrent/atomics.rb +1 -1
- data/lib/concurrent/configuration.rb +1 -1
- data/lib/concurrent/supervisor.rb +1 -1
- data/lib/concurrent/timer_task.rb +0 -36
- data/lib/concurrent/version.rb +1 -1
- data/lib/concurrent_ruby_ext.so +0 -0
- data/lib/extension_helper.rb +9 -0
- metadata +16 -148
- data/lib/concurrent/actor/actor.rb +0 -270
- data/lib/concurrent/actor/postable.rb +0 -102
- data/lib/concurrent/actors.rb +0 -2
- data/lib/concurrent/atomic/atomic.rb +0 -48
- data/lib/concurrent/runnable.rb +0 -90
- data/lib/concurrent/stoppable.rb +0 -20
- data/spec/concurrent/actor/actor_spec.rb +0 -376
- data/spec/concurrent/actor/postable_shared.rb +0 -218
- data/spec/concurrent/actress_spec.rb +0 -211
- data/spec/concurrent/agent_spec.rb +0 -500
- data/spec/concurrent/async_spec.rb +0 -352
- data/spec/concurrent/atomic/atomic_boolean_spec.rb +0 -172
- data/spec/concurrent/atomic/atomic_fixnum_spec.rb +0 -186
- data/spec/concurrent/atomic/atomic_spec.rb +0 -133
- data/spec/concurrent/atomic/condition_spec.rb +0 -171
- data/spec/concurrent/atomic/copy_on_notify_observer_set_spec.rb +0 -10
- data/spec/concurrent/atomic/copy_on_write_observer_set_spec.rb +0 -10
- data/spec/concurrent/atomic/count_down_latch_spec.rb +0 -151
- data/spec/concurrent/atomic/cyclic_barrier_spec.rb +0 -248
- data/spec/concurrent/atomic/event_spec.rb +0 -200
- data/spec/concurrent/atomic/observer_set_shared.rb +0 -242
- data/spec/concurrent/atomic/thread_local_var_spec.rb +0 -113
- data/spec/concurrent/channel/buffered_channel_spec.rb +0 -151
- data/spec/concurrent/channel/channel_spec.rb +0 -39
- data/spec/concurrent/channel/probe_spec.rb +0 -77
- data/spec/concurrent/channel/unbuffered_channel_spec.rb +0 -132
- data/spec/concurrent/collection/blocking_ring_buffer_spec.rb +0 -149
- data/spec/concurrent/collection/priority_queue_spec.rb +0 -317
- data/spec/concurrent/collection/ring_buffer_spec.rb +0 -126
- data/spec/concurrent/configuration_spec.rb +0 -69
- data/spec/concurrent/dataflow_spec.rb +0 -242
- data/spec/concurrent/delay_spec.rb +0 -91
- data/spec/concurrent/dereferenceable_shared.rb +0 -146
- data/spec/concurrent/exchanger_spec.rb +0 -66
- data/spec/concurrent/executor/cached_thread_pool_shared.rb +0 -115
- data/spec/concurrent/executor/fixed_thread_pool_shared.rb +0 -136
- data/spec/concurrent/executor/global_thread_pool_shared.rb +0 -35
- data/spec/concurrent/executor/immediate_executor_spec.rb +0 -12
- data/spec/concurrent/executor/java_cached_thread_pool_spec.rb +0 -44
- data/spec/concurrent/executor/java_fixed_thread_pool_spec.rb +0 -64
- data/spec/concurrent/executor/java_single_thread_executor_spec.rb +0 -21
- data/spec/concurrent/executor/java_thread_pool_executor_spec.rb +0 -71
- data/spec/concurrent/executor/per_thread_executor_spec.rb +0 -57
- data/spec/concurrent/executor/ruby_cached_thread_pool_spec.rb +0 -69
- data/spec/concurrent/executor/ruby_fixed_thread_pool_spec.rb +0 -39
- data/spec/concurrent/executor/ruby_single_thread_executor_spec.rb +0 -18
- data/spec/concurrent/executor/ruby_thread_pool_executor_spec.rb +0 -171
- data/spec/concurrent/executor/safe_task_executor_spec.rb +0 -103
- data/spec/concurrent/executor/thread_pool_class_cast_spec.rb +0 -52
- data/spec/concurrent/executor/thread_pool_executor_shared.rb +0 -155
- data/spec/concurrent/executor/thread_pool_shared.rb +0 -269
- data/spec/concurrent/executor/timer_set_spec.rb +0 -183
- data/spec/concurrent/future_spec.rb +0 -329
- data/spec/concurrent/ivar_spec.rb +0 -215
- data/spec/concurrent/mvar_spec.rb +0 -380
- data/spec/concurrent/obligation_shared.rb +0 -102
- data/spec/concurrent/obligation_spec.rb +0 -282
- data/spec/concurrent/observable_shared.rb +0 -177
- data/spec/concurrent/observable_spec.rb +0 -56
- data/spec/concurrent/options_parser_spec.rb +0 -71
- data/spec/concurrent/promise_spec.rb +0 -367
- data/spec/concurrent/runnable_shared.rb +0 -68
- data/spec/concurrent/runnable_spec.rb +0 -235
- data/spec/concurrent/scheduled_task_spec.rb +0 -340
- data/spec/concurrent/stoppable_shared.rb +0 -37
- data/spec/concurrent/supervisor_spec.rb +0 -1149
- data/spec/concurrent/timer_task_spec.rb +0 -256
- data/spec/concurrent/tvar_spec.rb +0 -137
- data/spec/concurrent/utility/processor_count_spec.rb +0 -20
- data/spec/concurrent/utility/timeout_spec.rb +0 -50
- data/spec/concurrent/utility/timer_spec.rb +0 -52
- data/spec/spec_helper.rb +0 -41
- data/spec/support/example_group_extensions.rb +0 -52
- data/spec/support/less_than_or_equal_to_matcher.rb +0 -5
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
module Concurrent
|
4
|
-
|
5
|
-
describe '#timer' do
|
6
|
-
|
7
|
-
it 'raises an exception when no block given' do
|
8
|
-
expect {
|
9
|
-
Concurrent::timer(0.1)
|
10
|
-
}.to raise_error(ArgumentError)
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'raises an exception if the interval is less than 0 seconds' do
|
14
|
-
expect {
|
15
|
-
Concurrent::timer(-1){ :foo }
|
16
|
-
}.to raise_error(ArgumentError)
|
17
|
-
end
|
18
|
-
|
19
|
-
it 'executes the block after the given number of seconds' do
|
20
|
-
start = Time.now.to_f
|
21
|
-
latch = CountDownLatch.new(1)
|
22
|
-
Concurrent::timer(0.5){ latch.count_down }
|
23
|
-
latch.count.should eq 1
|
24
|
-
latch.wait(0.1)
|
25
|
-
latch.count.should eq 1
|
26
|
-
latch.wait(1)
|
27
|
-
latch.count.should eq 0
|
28
|
-
end
|
29
|
-
|
30
|
-
it 'suppresses exceptions thrown by the block' do
|
31
|
-
expect {
|
32
|
-
Concurrent::timer(0.5){ raise Exception }
|
33
|
-
}.to_not raise_error
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'passes all arguments to the block' do
|
37
|
-
expected = nil
|
38
|
-
latch = CountDownLatch.new(1)
|
39
|
-
Concurrent::timer(0, 1, 2, 3) do |*args|
|
40
|
-
expected = args
|
41
|
-
latch.count_down
|
42
|
-
end
|
43
|
-
latch.wait(0.2)
|
44
|
-
expected.should eq [1, 2, 3]
|
45
|
-
end
|
46
|
-
|
47
|
-
it 'runs the task on the global timer pool' do
|
48
|
-
Concurrent.configuration.global_timer_set.should_receive(:post).with(0.1)
|
49
|
-
Concurrent::timer(0.1){ :foo }
|
50
|
-
end
|
51
|
-
end
|
52
|
-
end
|
data/spec/spec_helper.rb
DELETED
@@ -1,41 +0,0 @@
|
|
1
|
-
require 'simplecov'
|
2
|
-
require 'coveralls'
|
3
|
-
|
4
|
-
SimpleCov.formatter = SimpleCov::Formatter::MultiFormatter[
|
5
|
-
SimpleCov::Formatter::HTMLFormatter,
|
6
|
-
Coveralls::SimpleCov::Formatter
|
7
|
-
]
|
8
|
-
|
9
|
-
SimpleCov.start do
|
10
|
-
project_name 'concurrent-ruby'
|
11
|
-
add_filter '/coverage/'
|
12
|
-
add_filter '/doc/'
|
13
|
-
add_filter '/pkg/'
|
14
|
-
add_filter '/spec/'
|
15
|
-
add_filter '/tasks/'
|
16
|
-
end
|
17
|
-
|
18
|
-
require 'concurrent'
|
19
|
-
|
20
|
-
logger = Logger.new($stderr)
|
21
|
-
logger.level = Logger::INFO
|
22
|
-
Concurrent.configuration.logger = lambda do |level, progname, message = nil, &block|
|
23
|
-
logger.add level, message, progname, &block
|
24
|
-
end
|
25
|
-
|
26
|
-
# import all the support files
|
27
|
-
Dir[File.join(File.dirname(__FILE__), 'support/**/*.rb')].each { |f| require File.expand_path(f) }
|
28
|
-
|
29
|
-
RSpec.configure do |config|
|
30
|
-
config.order = 'random'
|
31
|
-
|
32
|
-
config.before(:each) do
|
33
|
-
#TODO: Better configuration management in individual test suites
|
34
|
-
reset_gem_configuration
|
35
|
-
end
|
36
|
-
|
37
|
-
config.after(:each) do
|
38
|
-
#TODO: Better thread management in individual test suites
|
39
|
-
kill_rogue_threads(false)
|
40
|
-
end
|
41
|
-
end
|
@@ -1,52 +0,0 @@
|
|
1
|
-
require 'rbconfig'
|
2
|
-
|
3
|
-
module Concurrent
|
4
|
-
module TestHelpers
|
5
|
-
def delta(v1, v2)
|
6
|
-
if block_given?
|
7
|
-
v1 = yield(v1)
|
8
|
-
v2 = yield(v2)
|
9
|
-
end
|
10
|
-
return (v1 - v2).abs
|
11
|
-
end
|
12
|
-
|
13
|
-
def mri?
|
14
|
-
RbConfig::CONFIG['ruby_install_name']=~ /^ruby$/i
|
15
|
-
end
|
16
|
-
|
17
|
-
def jruby?
|
18
|
-
RbConfig::CONFIG['ruby_install_name']=~ /^jruby$/i
|
19
|
-
end
|
20
|
-
|
21
|
-
def rbx?
|
22
|
-
RbConfig::CONFIG['ruby_install_name']=~ /^rbx$/i
|
23
|
-
end
|
24
|
-
|
25
|
-
def do_no_reset!
|
26
|
-
@do_not_reset = true
|
27
|
-
end
|
28
|
-
|
29
|
-
@@killed = false
|
30
|
-
|
31
|
-
def reset_gem_configuration
|
32
|
-
Concurrent.instance_variable_get(:@configuration).value = Concurrent::Configuration.new if @@killed
|
33
|
-
@@killed = false
|
34
|
-
end
|
35
|
-
|
36
|
-
def kill_rogue_threads(warning = true)
|
37
|
-
return if @do_not_reset
|
38
|
-
warn('[DEPRECATED] brute force thread control being used -- tests need updated') if warning
|
39
|
-
Thread.list.each do |thread|
|
40
|
-
thread.kill unless thread == Thread.current
|
41
|
-
end
|
42
|
-
@@killed = true
|
43
|
-
end
|
44
|
-
|
45
|
-
extend self
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
class RSpec::Core::ExampleGroup
|
50
|
-
include Concurrent::TestHelpers
|
51
|
-
extend Concurrent::TestHelpers
|
52
|
-
end
|