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.
Files changed (94) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +1 -1
  3. data/lib/concurrent.rb +3 -4
  4. data/lib/concurrent/atomic.rb +46 -0
  5. data/lib/concurrent/atomic_reference/concurrent_update_error.rb +7 -0
  6. data/lib/concurrent/atomic_reference/delegated_update.rb +28 -0
  7. data/lib/concurrent/atomic_reference/direct_update.rb +28 -0
  8. data/lib/concurrent/atomic_reference/jruby.rb +8 -0
  9. data/lib/concurrent/atomic_reference/mutex_atomic.rb +47 -0
  10. data/lib/concurrent/atomic_reference/numeric_cas_wrapper.rb +24 -0
  11. data/lib/concurrent/atomic_reference/rbx.rb +16 -0
  12. data/lib/concurrent/atomic_reference/ruby.rb +16 -0
  13. data/lib/concurrent/atomics.rb +1 -1
  14. data/lib/concurrent/configuration.rb +1 -1
  15. data/lib/concurrent/supervisor.rb +1 -1
  16. data/lib/concurrent/timer_task.rb +0 -36
  17. data/lib/concurrent/version.rb +1 -1
  18. data/lib/concurrent_ruby_ext.so +0 -0
  19. data/lib/extension_helper.rb +9 -0
  20. metadata +16 -148
  21. data/lib/concurrent/actor/actor.rb +0 -270
  22. data/lib/concurrent/actor/postable.rb +0 -102
  23. data/lib/concurrent/actors.rb +0 -2
  24. data/lib/concurrent/atomic/atomic.rb +0 -48
  25. data/lib/concurrent/runnable.rb +0 -90
  26. data/lib/concurrent/stoppable.rb +0 -20
  27. data/spec/concurrent/actor/actor_spec.rb +0 -376
  28. data/spec/concurrent/actor/postable_shared.rb +0 -218
  29. data/spec/concurrent/actress_spec.rb +0 -211
  30. data/spec/concurrent/agent_spec.rb +0 -500
  31. data/spec/concurrent/async_spec.rb +0 -352
  32. data/spec/concurrent/atomic/atomic_boolean_spec.rb +0 -172
  33. data/spec/concurrent/atomic/atomic_fixnum_spec.rb +0 -186
  34. data/spec/concurrent/atomic/atomic_spec.rb +0 -133
  35. data/spec/concurrent/atomic/condition_spec.rb +0 -171
  36. data/spec/concurrent/atomic/copy_on_notify_observer_set_spec.rb +0 -10
  37. data/spec/concurrent/atomic/copy_on_write_observer_set_spec.rb +0 -10
  38. data/spec/concurrent/atomic/count_down_latch_spec.rb +0 -151
  39. data/spec/concurrent/atomic/cyclic_barrier_spec.rb +0 -248
  40. data/spec/concurrent/atomic/event_spec.rb +0 -200
  41. data/spec/concurrent/atomic/observer_set_shared.rb +0 -242
  42. data/spec/concurrent/atomic/thread_local_var_spec.rb +0 -113
  43. data/spec/concurrent/channel/buffered_channel_spec.rb +0 -151
  44. data/spec/concurrent/channel/channel_spec.rb +0 -39
  45. data/spec/concurrent/channel/probe_spec.rb +0 -77
  46. data/spec/concurrent/channel/unbuffered_channel_spec.rb +0 -132
  47. data/spec/concurrent/collection/blocking_ring_buffer_spec.rb +0 -149
  48. data/spec/concurrent/collection/priority_queue_spec.rb +0 -317
  49. data/spec/concurrent/collection/ring_buffer_spec.rb +0 -126
  50. data/spec/concurrent/configuration_spec.rb +0 -69
  51. data/spec/concurrent/dataflow_spec.rb +0 -242
  52. data/spec/concurrent/delay_spec.rb +0 -91
  53. data/spec/concurrent/dereferenceable_shared.rb +0 -146
  54. data/spec/concurrent/exchanger_spec.rb +0 -66
  55. data/spec/concurrent/executor/cached_thread_pool_shared.rb +0 -115
  56. data/spec/concurrent/executor/fixed_thread_pool_shared.rb +0 -136
  57. data/spec/concurrent/executor/global_thread_pool_shared.rb +0 -35
  58. data/spec/concurrent/executor/immediate_executor_spec.rb +0 -12
  59. data/spec/concurrent/executor/java_cached_thread_pool_spec.rb +0 -44
  60. data/spec/concurrent/executor/java_fixed_thread_pool_spec.rb +0 -64
  61. data/spec/concurrent/executor/java_single_thread_executor_spec.rb +0 -21
  62. data/spec/concurrent/executor/java_thread_pool_executor_spec.rb +0 -71
  63. data/spec/concurrent/executor/per_thread_executor_spec.rb +0 -57
  64. data/spec/concurrent/executor/ruby_cached_thread_pool_spec.rb +0 -69
  65. data/spec/concurrent/executor/ruby_fixed_thread_pool_spec.rb +0 -39
  66. data/spec/concurrent/executor/ruby_single_thread_executor_spec.rb +0 -18
  67. data/spec/concurrent/executor/ruby_thread_pool_executor_spec.rb +0 -171
  68. data/spec/concurrent/executor/safe_task_executor_spec.rb +0 -103
  69. data/spec/concurrent/executor/thread_pool_class_cast_spec.rb +0 -52
  70. data/spec/concurrent/executor/thread_pool_executor_shared.rb +0 -155
  71. data/spec/concurrent/executor/thread_pool_shared.rb +0 -269
  72. data/spec/concurrent/executor/timer_set_spec.rb +0 -183
  73. data/spec/concurrent/future_spec.rb +0 -329
  74. data/spec/concurrent/ivar_spec.rb +0 -215
  75. data/spec/concurrent/mvar_spec.rb +0 -380
  76. data/spec/concurrent/obligation_shared.rb +0 -102
  77. data/spec/concurrent/obligation_spec.rb +0 -282
  78. data/spec/concurrent/observable_shared.rb +0 -177
  79. data/spec/concurrent/observable_spec.rb +0 -56
  80. data/spec/concurrent/options_parser_spec.rb +0 -71
  81. data/spec/concurrent/promise_spec.rb +0 -367
  82. data/spec/concurrent/runnable_shared.rb +0 -68
  83. data/spec/concurrent/runnable_spec.rb +0 -235
  84. data/spec/concurrent/scheduled_task_spec.rb +0 -340
  85. data/spec/concurrent/stoppable_shared.rb +0 -37
  86. data/spec/concurrent/supervisor_spec.rb +0 -1149
  87. data/spec/concurrent/timer_task_spec.rb +0 -256
  88. data/spec/concurrent/tvar_spec.rb +0 -137
  89. data/spec/concurrent/utility/processor_count_spec.rb +0 -20
  90. data/spec/concurrent/utility/timeout_spec.rb +0 -50
  91. data/spec/concurrent/utility/timer_spec.rb +0 -52
  92. data/spec/spec_helper.rb +0 -41
  93. data/spec/support/example_group_extensions.rb +0 -52
  94. 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
@@ -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
@@ -1,5 +0,0 @@
1
- RSpec::Matchers.define :be_less_than_or_equal_to do |expected|
2
- match do |actual|
3
- actual <= expected
4
- end
5
- end