concurrent-ruby 0.6.0 → 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 (110) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +55 -51
  3. data/lib/concurrent/actress/ad_hoc.rb +6 -0
  4. data/lib/concurrent/actress/context.rb +10 -8
  5. data/lib/concurrent/actress/core.rb +44 -20
  6. data/lib/concurrent/actress/core_delegations.rb +5 -0
  7. data/lib/concurrent/actress/envelope.rb +21 -5
  8. data/lib/concurrent/actress/reference.rb +5 -5
  9. data/lib/concurrent/actress.rb +152 -6
  10. data/lib/concurrent/agent.rb +9 -9
  11. data/lib/concurrent/atomic.rb +46 -0
  12. data/lib/concurrent/atomic_reference/concurrent_update_error.rb +7 -0
  13. data/lib/concurrent/atomic_reference/delegated_update.rb +28 -0
  14. data/lib/concurrent/atomic_reference/direct_update.rb +28 -0
  15. data/lib/concurrent/atomic_reference/jruby.rb +8 -0
  16. data/lib/concurrent/atomic_reference/mutex_atomic.rb +47 -0
  17. data/lib/concurrent/atomic_reference/numeric_cas_wrapper.rb +24 -0
  18. data/lib/concurrent/atomic_reference/rbx.rb +16 -0
  19. data/lib/concurrent/atomic_reference/ruby.rb +16 -0
  20. data/lib/concurrent/atomics.rb +1 -1
  21. data/lib/concurrent/configuration.rb +7 -2
  22. data/lib/concurrent/executor/ruby_thread_pool_executor.rb +0 -1
  23. data/lib/concurrent/executor/{one_by_one.rb → serialized_execution.rb} +21 -8
  24. data/lib/concurrent/executor/timer_set.rb +6 -1
  25. data/lib/concurrent/executors.rb +1 -1
  26. data/lib/concurrent/logging.rb +1 -1
  27. data/lib/concurrent/observable.rb +1 -1
  28. data/lib/concurrent/supervisor.rb +1 -1
  29. data/lib/concurrent/timer_task.rb +0 -36
  30. data/lib/concurrent/version.rb +1 -1
  31. data/lib/concurrent.rb +3 -4
  32. data/lib/concurrent_ruby_ext.so +0 -0
  33. data/lib/extension_helper.rb +9 -0
  34. metadata +19 -152
  35. data/lib/concurrent/actor/actor.rb +0 -270
  36. data/lib/concurrent/actor/postable.rb +0 -102
  37. data/lib/concurrent/actors.rb +0 -2
  38. data/lib/concurrent/actress/doc.md +0 -53
  39. data/lib/concurrent/atomic/atomic.rb +0 -48
  40. data/lib/concurrent/runnable.rb +0 -90
  41. data/lib/concurrent/stoppable.rb +0 -20
  42. data/spec/concurrent/actor/actor_spec.rb +0 -376
  43. data/spec/concurrent/actor/postable_shared.rb +0 -218
  44. data/spec/concurrent/actress_spec.rb +0 -191
  45. data/spec/concurrent/agent_spec.rb +0 -500
  46. data/spec/concurrent/async_spec.rb +0 -352
  47. data/spec/concurrent/atomic/atomic_boolean_spec.rb +0 -172
  48. data/spec/concurrent/atomic/atomic_fixnum_spec.rb +0 -186
  49. data/spec/concurrent/atomic/atomic_spec.rb +0 -133
  50. data/spec/concurrent/atomic/condition_spec.rb +0 -171
  51. data/spec/concurrent/atomic/copy_on_notify_observer_set_spec.rb +0 -10
  52. data/spec/concurrent/atomic/copy_on_write_observer_set_spec.rb +0 -10
  53. data/spec/concurrent/atomic/count_down_latch_spec.rb +0 -151
  54. data/spec/concurrent/atomic/cyclic_barrier_spec.rb +0 -248
  55. data/spec/concurrent/atomic/event_spec.rb +0 -200
  56. data/spec/concurrent/atomic/observer_set_shared.rb +0 -242
  57. data/spec/concurrent/atomic/thread_local_var_spec.rb +0 -113
  58. data/spec/concurrent/channel/buffered_channel_spec.rb +0 -151
  59. data/spec/concurrent/channel/channel_spec.rb +0 -39
  60. data/spec/concurrent/channel/probe_spec.rb +0 -77
  61. data/spec/concurrent/channel/unbuffered_channel_spec.rb +0 -132
  62. data/spec/concurrent/collection/blocking_ring_buffer_spec.rb +0 -149
  63. data/spec/concurrent/collection/priority_queue_spec.rb +0 -317
  64. data/spec/concurrent/collection/ring_buffer_spec.rb +0 -126
  65. data/spec/concurrent/configuration_spec.rb +0 -71
  66. data/spec/concurrent/dataflow_spec.rb +0 -242
  67. data/spec/concurrent/delay_spec.rb +0 -91
  68. data/spec/concurrent/dereferenceable_shared.rb +0 -146
  69. data/spec/concurrent/exchanger_spec.rb +0 -66
  70. data/spec/concurrent/executor/cached_thread_pool_shared.rb +0 -115
  71. data/spec/concurrent/executor/fixed_thread_pool_shared.rb +0 -136
  72. data/spec/concurrent/executor/global_thread_pool_shared.rb +0 -35
  73. data/spec/concurrent/executor/immediate_executor_spec.rb +0 -12
  74. data/spec/concurrent/executor/java_cached_thread_pool_spec.rb +0 -44
  75. data/spec/concurrent/executor/java_fixed_thread_pool_spec.rb +0 -64
  76. data/spec/concurrent/executor/java_single_thread_executor_spec.rb +0 -21
  77. data/spec/concurrent/executor/java_thread_pool_executor_spec.rb +0 -71
  78. data/spec/concurrent/executor/per_thread_executor_spec.rb +0 -57
  79. data/spec/concurrent/executor/ruby_cached_thread_pool_spec.rb +0 -69
  80. data/spec/concurrent/executor/ruby_fixed_thread_pool_spec.rb +0 -39
  81. data/spec/concurrent/executor/ruby_single_thread_executor_spec.rb +0 -18
  82. data/spec/concurrent/executor/ruby_thread_pool_executor_spec.rb +0 -171
  83. data/spec/concurrent/executor/safe_task_executor_spec.rb +0 -103
  84. data/spec/concurrent/executor/thread_pool_class_cast_spec.rb +0 -52
  85. data/spec/concurrent/executor/thread_pool_executor_shared.rb +0 -155
  86. data/spec/concurrent/executor/thread_pool_shared.rb +0 -239
  87. data/spec/concurrent/executor/timer_set_spec.rb +0 -183
  88. data/spec/concurrent/future_spec.rb +0 -329
  89. data/spec/concurrent/ivar_spec.rb +0 -215
  90. data/spec/concurrent/mvar_spec.rb +0 -380
  91. data/spec/concurrent/obligation_shared.rb +0 -102
  92. data/spec/concurrent/obligation_spec.rb +0 -282
  93. data/spec/concurrent/observable_shared.rb +0 -177
  94. data/spec/concurrent/observable_spec.rb +0 -56
  95. data/spec/concurrent/options_parser_spec.rb +0 -71
  96. data/spec/concurrent/promise_spec.rb +0 -367
  97. data/spec/concurrent/runnable_shared.rb +0 -68
  98. data/spec/concurrent/runnable_spec.rb +0 -235
  99. data/spec/concurrent/scheduled_task_spec.rb +0 -342
  100. data/spec/concurrent/stoppable_shared.rb +0 -37
  101. data/spec/concurrent/supervisor_spec.rb +0 -1148
  102. data/spec/concurrent/timer_task_spec.rb +0 -258
  103. data/spec/concurrent/tvar_spec.rb +0 -137
  104. data/spec/concurrent/utility/processor_count_spec.rb +0 -20
  105. data/spec/concurrent/utility/timeout_spec.rb +0 -50
  106. data/spec/concurrent/utility/timer_spec.rb +0 -52
  107. data/spec/spec_helper.rb +0 -31
  108. data/spec/support/example_group_extensions.rb +0 -48
  109. data/spec/support/less_than_or_equal_to_matcher.rb +0 -5
  110. /data/{LICENSE → LICENSE.txt} +0 -0
@@ -1,113 +0,0 @@
1
- require 'spec_helper'
2
- require 'rbconfig'
3
-
4
- module Concurrent
5
-
6
- describe ThreadLocalVar do
7
-
8
- subject{ ThreadLocalVar.new }
9
-
10
- context '#initialize' do
11
-
12
- it 'can set an initial value' do
13
- v = ThreadLocalVar.new(14)
14
- v.value.should eq 14
15
- end
16
-
17
- it 'sets nil as a default initial value' do
18
- v = ThreadLocalVar.new
19
- v.value.should be_nil
20
- end
21
-
22
- it 'sets the same initial value for all threads' do
23
- v = ThreadLocalVar.new(14)
24
- t1 = Thread.new { v.value }
25
- t2 = Thread.new { v.value }
26
- t1.value.should eq 14
27
- t2.value.should eq 14
28
- end
29
-
30
- if jruby?
31
- it 'uses ThreadLocalJavaStorage' do
32
- subject.class.ancestors.should include(Concurrent::ThreadLocalJavaStorage)
33
- end
34
- elsif rbx? || RbConfig::CONFIG['ruby_version'] =~ /^1\.9/
35
- it 'uses ThreadLocalOldStorage' do
36
- subject.class.ancestors.should include(Concurrent::ThreadLocalOldStorage)
37
- end
38
- else
39
- it 'uses ThreadLocalNewStorage' do
40
- subject.class.ancestors.should include(Concurrent::ThreadLocalNewStorage)
41
- end
42
- end
43
- end
44
-
45
- context '#value' do
46
-
47
- it 'returns the current value' do
48
- v = ThreadLocalVar.new(14)
49
- v.value.should eq 14
50
- end
51
-
52
- it 'returns the value after modification' do
53
- v = ThreadLocalVar.new(14)
54
- v.value = 2
55
- v.value.should eq 2
56
- end
57
-
58
- end
59
-
60
- context '#value=' do
61
-
62
- it 'sets a new value' do
63
- v = ThreadLocalVar.new(14)
64
- v.value = 2
65
- v.value.should eq 2
66
- end
67
-
68
- it 'returns the new value' do
69
- v = ThreadLocalVar.new(14)
70
- (v.value = 2).should eq 2
71
- end
72
-
73
- it 'does not modify the initial value for other threads' do
74
- v = ThreadLocalVar.new(14)
75
- v.value = 2
76
- t = Thread.new { v.value }
77
- t.value.should eq 14
78
- end
79
-
80
- it 'does not modify the value for other threads' do
81
- v = ThreadLocalVar.new(14)
82
- v.value = 2
83
-
84
- b1 = CountDownLatch.new(2)
85
- b2 = CountDownLatch.new(2)
86
-
87
- t1 = Thread.new do
88
- b1.count_down
89
- b1.wait
90
- v.value = 1
91
- b2.count_down
92
- b2.wait
93
- v.value
94
- end
95
-
96
- t2 = Thread.new do
97
- b1.count_down
98
- b1.wait
99
- v.value = 2
100
- b2.count_down
101
- b2.wait
102
- v.value
103
- end
104
-
105
- t1.value.should eq 1
106
- t2.value.should eq 2
107
- end
108
-
109
- end
110
-
111
- end
112
-
113
- end
@@ -1,151 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Concurrent
4
-
5
- describe BufferedChannel do
6
-
7
- let(:size) { 2 }
8
- let!(:channel) { BufferedChannel.new(size) }
9
- let(:probe) { Channel::Probe.new }
10
-
11
- context 'without timeout' do
12
-
13
- describe '#push' do
14
- it 'adds elements to buffer' do
15
- channel.buffer_queue_size.should be 0
16
-
17
- channel.push('a')
18
- channel.push('a')
19
-
20
- channel.buffer_queue_size.should be 2
21
- end
22
-
23
- it 'should block when buffer is full' do
24
- channel.push 1
25
- channel.push 2
26
-
27
- t = Thread.new { channel.push 3 }
28
- sleep(0.05)
29
- t.status.should eq 'sleep'
30
- end
31
-
32
- it 'restarts thread when buffer is no more full' do
33
- channel.push 'hi'
34
- channel.push 'foo'
35
-
36
- result = nil
37
-
38
- Thread.new { channel.push 'bar'; result = 42 }
39
-
40
- sleep(0.1)
41
-
42
- channel.pop
43
-
44
- sleep(0.1)
45
-
46
- result.should eq 42
47
- end
48
-
49
- it 'should assign value to a probe if probe set is not empty' do
50
- channel.select(probe)
51
- Thread.new { sleep(0.1); channel.push 3 }
52
- probe.value.should eq 3
53
- end
54
- end
55
-
56
- describe '#pop' do
57
- it 'should block if buffer is empty' do
58
- t = Thread.new { channel.pop }
59
- sleep(0.05)
60
- t.status.should eq 'sleep'
61
- end
62
-
63
- it 'returns value if buffer is not empty' do
64
- channel.push 1
65
- result = channel.pop
66
-
67
- result.should eq 1
68
- end
69
-
70
- it 'removes the first value from the buffer' do
71
- channel.push 'a'
72
- channel.push 'b'
73
-
74
- channel.pop.should eq 'a'
75
- channel.buffer_queue_size.should eq 1
76
- end
77
- end
78
-
79
- end
80
-
81
- describe 'select' do
82
-
83
- it 'does not block' do
84
- t = Thread.new { channel.select(probe) }
85
-
86
- sleep(0.05)
87
-
88
- t.status.should eq false
89
- end
90
-
91
- it 'gets notified by writer thread' do
92
- channel.select(probe)
93
-
94
- Thread.new { channel.push 82 }
95
-
96
- probe.value.should eq 82
97
- end
98
-
99
- end
100
-
101
- context 'already set probes' do
102
- context 'empty buffer' do
103
- it 'discards already set probes' do
104
- probe.set('set value')
105
-
106
- channel.select(probe)
107
-
108
- channel.push 27
109
-
110
- channel.buffer_queue_size.should eq 1
111
- channel.probe_set_size.should eq 0
112
- end
113
- end
114
-
115
- context 'empty probe set' do
116
- it 'discards set probe' do
117
- probe.set('set value')
118
-
119
- channel.push 82
120
-
121
- channel.select(probe)
122
-
123
- channel.buffer_queue_size.should eq 1
124
-
125
- channel.pop.should eq 82
126
-
127
- end
128
- end
129
- end
130
-
131
- describe 'probe set' do
132
-
133
- it 'has size zero after creation' do
134
- channel.probe_set_size.should eq 0
135
- end
136
-
137
- it 'increases size after a select' do
138
- channel.select(probe)
139
- channel.probe_set_size.should eq 1
140
- end
141
-
142
- it 'decreases size after a removal' do
143
- channel.select(probe)
144
- channel.remove_probe(probe)
145
- channel.probe_set_size.should eq 0
146
- end
147
-
148
- end
149
-
150
- end
151
- end
@@ -1,39 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Concurrent
4
-
5
- describe Channel do
6
-
7
- describe '.select' do
8
-
9
- context 'without timeout' do
10
- it 'returns the first value available on a channel' do
11
- channels = [ UnbufferedChannel.new, UnbufferedChannel.new]
12
-
13
- Thread.new { channels[1].push 77 }
14
-
15
- value, channel = Channel.select(*channels)
16
-
17
- value.should eq 77
18
- channel.should be channels[1]
19
- end
20
-
21
- it 'cleans up' do
22
- channels = [ UnbufferedChannel.new, UnbufferedChannel.new]
23
- channels.each { |ch| ch.stub(:remove_probe).with( an_instance_of(Channel::Probe) )}
24
-
25
- Thread.new { channels[1].push 77 }
26
-
27
- value, channel = Channel.select(*channels)
28
-
29
- value.should eq 77
30
- channel.should be channels[1]
31
-
32
- channels.each { |ch| expect(ch).to have_received(:remove_probe).with( an_instance_of(Channel::Probe) ) }
33
- end
34
- end
35
-
36
- end
37
-
38
- end
39
- end
@@ -1,77 +0,0 @@
1
- require 'spec_helper'
2
- require_relative '../observable_shared'
3
-
4
- module Concurrent
5
-
6
- describe Channel::Probe do
7
-
8
- let(:channel) { Object.new }
9
- let(:probe) { Channel::Probe.new }
10
-
11
- describe 'behavior' do
12
-
13
- # observable
14
-
15
- subject{ Channel::Probe.new }
16
-
17
- def trigger_observable(observable)
18
- observable.set('value')
19
- end
20
-
21
- it_should_behave_like :observable
22
- end
23
-
24
- describe '#set_unless_assigned' do
25
- context 'empty probe' do
26
- it 'assigns the value' do
27
- probe.set_unless_assigned(32, channel)
28
- probe.value.should eq 32
29
- end
30
-
31
- it 'assign the channel' do
32
- probe.set_unless_assigned(32, channel)
33
- probe.channel.should be channel
34
- end
35
-
36
- it 'returns true' do
37
- probe.set_unless_assigned('hi', channel).should eq true
38
- end
39
- end
40
-
41
- context 'fulfilled probe' do
42
- before(:each) { probe.set([27, nil]) }
43
-
44
- it 'does not assign the value' do
45
- probe.set_unless_assigned(88, channel)
46
- probe.value.should eq 27
47
- end
48
-
49
- it 'returns false' do
50
- probe.set_unless_assigned('hello', channel).should eq false
51
- end
52
- end
53
-
54
- context 'rejected probe' do
55
- before(:each) { probe.fail }
56
-
57
- it 'does not assign the value' do
58
- probe.set_unless_assigned(88, channel)
59
- probe.should be_rejected
60
- end
61
-
62
- it 'has a nil value' do
63
- probe.value.should be_nil
64
- end
65
-
66
- it 'has a nil channel' do
67
- probe.channel.should be_nil
68
- end
69
-
70
- it 'returns false' do
71
- probe.set_unless_assigned('hello', channel).should eq false
72
- end
73
- end
74
- end
75
-
76
- end
77
- end
@@ -1,132 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Concurrent
4
-
5
- describe UnbufferedChannel do
6
-
7
- let!(:channel) { subject }
8
- let(:probe) { Channel::Probe.new }
9
-
10
- context 'with one thread' do
11
-
12
- context 'without timeout' do
13
-
14
- describe '#push' do
15
- it 'should block' do
16
- t = Thread.new { channel.push 5 }
17
- sleep(0.05)
18
- t.status.should eq 'sleep'
19
- end
20
- end
21
-
22
- describe '#pop' do
23
- it 'should block' do
24
- t = Thread.new { channel.pop }
25
- sleep(0.05)
26
- t.status.should eq 'sleep'
27
- end
28
- end
29
-
30
- end
31
-
32
- end
33
-
34
- context 'cooperating threads' do
35
-
36
- it 'passes the pushed value to thread waiting on pop' do
37
- result = nil
38
-
39
- Thread.new { channel.push 42 }
40
- Thread.new { result = channel.pop; }
41
-
42
- sleep(0.1)
43
-
44
- result.should eq 42
45
- end
46
-
47
- it 'passes the pushed value to only one thread' do
48
- result = []
49
-
50
- Thread.new { channel.push 37 }
51
- Thread.new { result << channel.pop }
52
- Thread.new { result << channel.pop }
53
-
54
- sleep(0.1)
55
-
56
- result.should have(1).items
57
- end
58
-
59
- it 'gets the pushed value when ready' do
60
- result = nil
61
-
62
- Thread.new { result = channel.pop; }
63
- Thread.new { channel.push 57 }
64
-
65
- sleep(0.1)
66
-
67
- result.should eq 57
68
- end
69
- end
70
-
71
- describe 'select' do
72
-
73
- it 'does not block' do
74
- t = Thread.new { channel.select(probe) }
75
-
76
- sleep(0.05)
77
-
78
- t.status.should eq false
79
- end
80
-
81
- it 'gets notified by writer thread' do
82
- channel.select(probe)
83
-
84
- Thread.new { channel.push 82 }
85
-
86
- probe.value.should eq 82
87
- end
88
-
89
- it 'ignores already set probes and waits for a new one' do
90
- probe.set(27)
91
-
92
- channel.select(probe)
93
-
94
- t = Thread.new { channel.push 72 }
95
-
96
- sleep(0.05)
97
-
98
- t.status.should eq 'sleep'
99
-
100
- new_probe = Channel::Probe.new
101
-
102
- channel.select(new_probe)
103
-
104
- sleep(0.05)
105
-
106
- new_probe.value.should eq 72
107
- end
108
-
109
- end
110
-
111
- describe 'probe set' do
112
-
113
- it 'has size zero after creation' do
114
- channel.probe_set_size.should eq 0
115
- end
116
-
117
- it 'increases size after a select' do
118
- channel.select(probe)
119
- channel.probe_set_size.should eq 1
120
- end
121
-
122
- it 'decreases size after a removal' do
123
- channel.select(probe)
124
- channel.remove_probe(probe)
125
- channel.probe_set_size.should eq 0
126
- end
127
-
128
- end
129
-
130
-
131
- end
132
- end
@@ -1,149 +0,0 @@
1
- require 'spec_helper'
2
-
3
- module Concurrent
4
-
5
- describe BlockingRingBuffer do
6
-
7
- let(:capacity) { 3 }
8
- let(:buffer) { BlockingRingBuffer.new(capacity) }
9
-
10
- def fill_buffer
11
- capacity.times { buffer.put 3 }
12
- end
13
-
14
- describe '#capacity' do
15
- it 'returns the value passed in constructor' do
16
- buffer.capacity.should eq capacity
17
- end
18
- end
19
-
20
- describe '#count' do
21
- it 'is zero when created' do
22
- buffer.count.should eq 0
23
- end
24
-
25
- it 'increases when an element is added' do
26
- buffer.put 5
27
- buffer.count.should eq 1
28
-
29
- buffer.put 1
30
- buffer.count.should eq 2
31
- end
32
-
33
- it 'decreases when an element is removed' do
34
- buffer.put 10
35
-
36
- buffer.take
37
-
38
- buffer.count.should eq 0
39
- end
40
- end
41
-
42
- describe '#empty?' do
43
- it 'is true when count is zero' do
44
- buffer.empty?.should be_true
45
- end
46
-
47
- it 'is false when count is not zero' do
48
- buffer.put 82
49
- buffer.empty?.should be_false
50
- end
51
- end
52
-
53
- describe '#full?' do
54
- it 'is true when count is capacity' do
55
- fill_buffer
56
- buffer.full?.should be_true
57
- end
58
-
59
- it 'is false when count is not capacity' do
60
- buffer.full?.should be_false
61
- end
62
- end
63
-
64
- describe '#put' do
65
- it 'block when buffer is full' do
66
- fill_buffer
67
-
68
- t = Thread.new { buffer.put 32 }
69
-
70
- sleep(0.1)
71
-
72
- t.status.should eq 'sleep'
73
- end
74
-
75
- it 'continues when an element is removed' do
76
- latch = CountDownLatch.new(1)
77
-
78
- Thread.new { (capacity + 1).times { buffer.put 'hi' }; latch.count_down }
79
- Thread.new { sleep(0.1); buffer.take }
80
-
81
- latch.wait(0.2).should be_true
82
- end
83
- end
84
-
85
- describe '#take' do
86
- it 'blocks when buffer is empty' do
87
- t = Thread.new { buffer.take }
88
-
89
- sleep(0.1)
90
-
91
- t.status.should eq 'sleep'
92
- end
93
-
94
- it 'continues when an element is added' do
95
- latch = CountDownLatch.new(1)
96
-
97
- Thread.new { buffer.take; latch.count_down }
98
- Thread.new { sleep(0.1); buffer.put 3 }
99
-
100
- latch.wait(0.2).should be_true
101
- end
102
-
103
- it 'returns the first added value' do
104
- buffer.put 'hi'
105
- buffer.put 'foo'
106
- buffer.put 'bar'
107
-
108
- buffer.take.should eq 'hi'
109
- buffer.take.should eq 'foo'
110
- buffer.take.should eq 'bar'
111
- end
112
- end
113
-
114
- describe '#peek' do
115
- context 'buffer empty' do
116
- it 'returns nil when buffer is empty' do
117
- buffer.peek.should be_nil
118
- end
119
- end
120
-
121
- context 'not empty' do
122
-
123
- before(:each) { buffer.put 'element' }
124
-
125
- it 'returns the first value' do
126
- buffer.peek.should eq 'element'
127
- end
128
-
129
- it 'does not change buffer' do
130
- buffer.peek
131
- buffer.count.should eq 1
132
- end
133
- end
134
- end
135
-
136
- context 'circular condition' do
137
- it 'can filled many times' do
138
- fill_buffer
139
- capacity.times { buffer.take }
140
-
141
- buffer.put 'hi'
142
-
143
- buffer.take.should eq 'hi'
144
- buffer.capacity.should eq capacity
145
- end
146
- end
147
-
148
- end
149
- end