agent 0.11.0 → 0.12.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cb98d2b1912834ca7a296fb6dd1895c90c62d371
4
- data.tar.gz: ea72c26e2be6e8bbd7ef710a2a2a87e0ef8141c6
3
+ metadata.gz: 49fb01139596ed5444f28e53516a1567faa9ff2c
4
+ data.tar.gz: 74fdbf57532666cf21f26ed158d956a8a8bdfabf
5
5
  SHA512:
6
- metadata.gz: c3bcd58b2138db30b0c1f732673b7b9654f90b26358cf89c480efab7aa7ef8e9b5ae876949d726f64c93459cd8b995b35ff5202bf2665be23656632340b64094
7
- data.tar.gz: 30116a292e6d8e36894b2da56638bda87a817be19355f4c7ffe0d70a243d3a11c9cc13e913705c4eec067f3a95c75badd62b42279c469874764adef23e20097e
6
+ metadata.gz: 5dd1e17dba7f99429440b138012251937059c4abfa2534b9302980ad97edb044e34dfc00a7910717c5f5b109a5e1073d3e549d14deec2943f5cb2955397524c2
7
+ data.tar.gz: b164a7c641eddd088cdeb970f5bd319831cdfff523e377f4da99edc5e6ea54cd3ca4cd09d11ef2a93d3c2b877a7aa94efb966bab22224abf759a93dd6ffa13f0
@@ -1,16 +1,22 @@
1
+ sudo: false # to run on the new travis container infrastructure
1
2
  language: ruby
3
+ addons:
4
+ apt:
5
+ packages:
6
+ - idn
7
+ - build-essential # this and following ensure rubinius is setup ok
8
+ - bison
9
+ - ruby-dev
10
+ - rake
11
+ - lib1g-dev
12
+ - libyaml-dev
13
+ - libssl-dev
14
+ - libreadline-dev
15
+ - libncurses5-dev
16
+ - llvm
17
+ - llvm-dev
18
+ - libeditline-dev
19
+ - libedit-dev
2
20
  rvm:
3
- - 1.8.7
4
- - ree
5
- - 1.9.2
6
- - 1.9.3
7
- - 2.0
8
- - 2.1
9
- - 2.2
10
- - ruby-head
11
- - jruby-18mode
12
- - jruby-19mode
13
- - jruby-head
14
- - rbx-2.2
15
- - rbx-2.4
16
-
21
+ - 2.3.1
22
+ - jruby
@@ -1,26 +1,26 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- agent (0.10.0)
4
+ agent (0.11.0)
5
5
 
6
6
  GEM
7
7
  remote: http://rubygems.org/
8
8
  specs:
9
9
  diff-lcs (1.2.5)
10
- rake (10.4.2)
11
- rspec (3.2.0)
12
- rspec-core (~> 3.2.0)
13
- rspec-expectations (~> 3.2.0)
14
- rspec-mocks (~> 3.2.0)
15
- rspec-core (3.2.0)
16
- rspec-support (~> 3.2.0)
17
- rspec-expectations (3.2.0)
10
+ rake (11.2.2)
11
+ rspec (3.5.0)
12
+ rspec-core (~> 3.5.0)
13
+ rspec-expectations (~> 3.5.0)
14
+ rspec-mocks (~> 3.5.0)
15
+ rspec-core (3.5.3)
16
+ rspec-support (~> 3.5.0)
17
+ rspec-expectations (3.5.0)
18
18
  diff-lcs (>= 1.2.0, < 2.0)
19
- rspec-support (~> 3.2.0)
20
- rspec-mocks (3.2.0)
19
+ rspec-support (~> 3.5.0)
20
+ rspec-mocks (3.5.0)
21
21
  diff-lcs (>= 1.2.0, < 2.0)
22
- rspec-support (~> 3.2.0)
23
- rspec-support (3.2.1)
22
+ rspec-support (~> 3.5.0)
23
+ rspec-support (3.5.0)
24
24
 
25
25
  PLATFORMS
26
26
  java
@@ -30,3 +30,6 @@ DEPENDENCIES
30
30
  agent!
31
31
  rake
32
32
  rspec
33
+
34
+ BUNDLED WITH
35
+ 1.12.5
@@ -26,7 +26,6 @@ module Agent
26
26
  @queue = Queues.register(@name, @type, @max)
27
27
  end
28
28
 
29
-
30
29
  # Serialization methods
31
30
 
32
31
  def marshal_load(ary)
@@ -45,8 +44,8 @@ module Agent
45
44
 
46
45
  def send(object, options={})
47
46
  check_direction(:send)
48
- q = queue
49
- raise Errors::ChannelClosed unless q
47
+ raise Errors::ChannelClosed if @closed
48
+ q = @queue
50
49
  q.push(object, {:skip_marshal => @skip_marshal}.merge(options))
51
50
  end
52
51
  alias :push :send
@@ -55,23 +54,18 @@ module Agent
55
54
  def push?; queue.push?; end
56
55
  alias :send? :push?
57
56
 
58
-
59
57
  # Receiving methods
60
58
 
61
59
  def receive(options={})
62
60
  check_direction(:receive)
63
61
  q = queue
64
- return q.pop(options) if q
65
- pop = Pop.new(options)
66
- pop.close
67
- [pop.object, false]
62
+ return q.pop(options)
68
63
  end
69
64
  alias :pop :receive
70
65
 
71
66
  def pop?; queue.pop?; end
72
67
  alias :receive? :pop?
73
68
 
74
-
75
69
  # Closing methods
76
70
 
77
71
  def close
@@ -79,7 +73,6 @@ module Agent
79
73
  raise Errors::ChannelClosed if @closed
80
74
  @closed = true
81
75
  @queue.close
82
- @queue = nil
83
76
  Queues.delete(@name)
84
77
  end
85
78
  end
@@ -101,7 +94,6 @@ module Agent
101
94
  as_direction_only(:receive)
102
95
  end
103
96
 
104
-
105
97
  private
106
98
 
107
99
  def as_direction_only(direction)
@@ -28,7 +28,8 @@ module Agent
28
28
  until @received || @closed
29
29
  @cvar.wait(@mutex)
30
30
  end
31
- return received?
31
+ return false if @closed
32
+ received?
32
33
  end
33
34
  end
34
35
 
@@ -1,10 +1,20 @@
1
+ require "forwardable"
2
+
1
3
  require "agent/queue/buffered"
2
4
  require "agent/queue/unbuffered"
3
5
  require "agent/errors"
4
6
 
5
7
  module Agent
6
8
  class Queue
7
- attr_reader :type, :queue, :operations, :pushes, :pops, :mutex
9
+ extend Forwardable
10
+ attr_reader :type, :operations
11
+
12
+ # protected attributes
13
+ attr_reader :mutex, :queue, :pops, :pushes
14
+ protected :mutex, :queue, :pops, :pushes
15
+
16
+ # size is the queue size
17
+ def_delegators :@queue, :size
8
18
 
9
19
  def initialize(type)
10
20
  @type = type
@@ -47,12 +57,8 @@ module Agent
47
57
  def close
48
58
  mutex.synchronize do
49
59
  raise Errors::ChannelClosed if @closed
50
- @closed = true
51
60
  @operations.each{|o| o.close }
52
- @operations.clear
53
- @queue.clear
54
- @pushes.clear
55
- @pops.clear
61
+ @closed = true
56
62
 
57
63
  reset_custom_state
58
64
  end
@@ -82,7 +88,7 @@ module Agent
82
88
  pop = Pop.new(options)
83
89
 
84
90
  mutex.synchronize do
85
- pop.close if @closed
91
+ pop.close if @closed and queue.size == 0
86
92
  operations << pop
87
93
  pops << pop
88
94
  process
@@ -31,9 +31,11 @@ module Agent
31
31
  loop do
32
32
  if operation.is_a?(Push)
33
33
  if push?
34
- operation.receive do |obj|
35
- @size += 1
36
- queue.push(obj)
34
+ unless operation.closed?
35
+ operation.receive do |obj|
36
+ @size += 1
37
+ queue.push(obj)
38
+ end
37
39
  end
38
40
  operations.delete(operation)
39
41
  pushes.delete(operation)
@@ -1,3 +1,3 @@
1
1
  module Agent
2
- VERSION = "0.11.0"
2
+ VERSION = "0.12.0"
3
3
  end
@@ -79,7 +79,7 @@ describe Agent::Channel do
79
79
 
80
80
  context "closing" do
81
81
  before do
82
- @c = channel!(String)
82
+ @c = channel!(Integer, 3)
83
83
  end
84
84
 
85
85
  it "not raise an error the first time it is called" do
@@ -113,6 +113,16 @@ describe Agent::Channel do
113
113
  @c.close
114
114
  expect(@c.receive).to eq([nil, false])
115
115
  end
116
+
117
+ it "should return buffered items from a closed channel" do
118
+ @c << 1
119
+ @c << 2
120
+ @c.close
121
+ expect(@c.receive).to eq([1, true])
122
+ expect(@c.receive).to eq([2, true])
123
+ expect(@c.receive).to eq([nil, false])
124
+ expect(@c.receive).to eq([nil, false])
125
+ end
116
126
  end
117
127
 
118
128
  context "deadlock" do
@@ -28,7 +28,7 @@ describe Agent::Pop do
28
28
 
29
29
  s, _ = @ack.receive
30
30
 
31
- expect(Time.now - s).to be_within(0.01).of(0)
31
+ expect(Time.now - s).to be_within(0.2).of(0)
32
32
  end
33
33
 
34
34
  it "should continue when closed" do
@@ -38,7 +38,7 @@ describe Agent::Pop do
38
38
 
39
39
  s, _ = @ack.receive
40
40
 
41
- expect(Time.now - s).to be_within(0.01).of(0)
41
+ expect(Time.now - s).to be_within(0.2).of(0)
42
42
  end
43
43
 
44
44
  it "should be able to be gracefully rolled back" do
@@ -56,7 +56,7 @@ describe Agent::Pop do
56
56
 
57
57
  s, _ = @ack.receive
58
58
 
59
- expect(Time.now - s).to be_within(0.01).of(0.2)
59
+ expect(Time.now - s).to be_within(0.05).of(0.2)
60
60
  end
61
61
  end
62
62
 
@@ -2,7 +2,7 @@ require "spec_helper"
2
2
 
3
3
  describe Agent::Queue do
4
4
 
5
- context "with an buffered queue" do
5
+ context "with a buffered queue" do
6
6
  before do
7
7
  @queue = Agent::Queue::Buffered.new(String, 2)
8
8
  end
@@ -20,7 +20,7 @@ describe Agent::Queue do
20
20
  expect{ Agent::Queue::Buffered.new(String, -1) }.to raise_error(Agent::Errors::InvalidQueueSize)
21
21
  end
22
22
 
23
- it "should raise an erro when an object of an invalid type is pushed" do
23
+ it "should raise an error when an object of an invalid type is pushed" do
24
24
  expect { @queue.push(1) }.to raise_error(Agent::Errors::InvalidType)
25
25
  end
26
26
 
@@ -144,22 +144,8 @@ describe Agent::Queue do
144
144
  expect(@push3).to be_closed
145
145
  end
146
146
 
147
- it "should clear all waiting operations" do
148
- expect(@queue.operations.size).to eq(1)
149
- expect(@queue.pushes.size).to eq(1)
150
- @queue.close
151
- expect(@queue.operations.size).to eq(0)
152
- expect(@queue.pushes.size).to eq(0)
153
- end
154
-
155
- it "should clear all elements at rest" do
156
- expect(@queue.queue.size).to eq(2)
157
- @queue.close
158
- expect(@queue.queue.size).to eq(0)
159
- end
160
-
161
147
  context "after it is closed" do
162
- before{ @queue.close }
148
+ before(:example) { @queue.close }
163
149
 
164
150
  it "should raise an error when #close is called again" do
165
151
  expect{ @queue.close }.to raise_error(Agent::Errors::ChannelClosed)
@@ -169,7 +155,9 @@ describe Agent::Queue do
169
155
  expect{ @queue.push("1") }.to raise_error(Agent::Errors::ChannelClosed)
170
156
  end
171
157
 
172
- it "should return [nil, false] when popping from the queue" do
158
+ it "should return the buffered items when popping from the queue" do
159
+ 2.times { expect(@queue.pop).to eq(["1", true]) }
160
+ expect(@queue.pop).to eq([nil, false])
173
161
  expect(@queue.pop).to eq([nil, false])
174
162
  end
175
163
  end
@@ -323,14 +311,6 @@ describe Agent::Queue do
323
311
  expect(@push2).to be_closed
324
312
  end
325
313
 
326
- it "should clear all waiting operations" do
327
- expect(@queue.operations.size).to eq(2)
328
- expect(@queue.pushes.size).to eq(2)
329
- @queue.close
330
- expect(@queue.operations.size).to eq(0)
331
- expect(@queue.pushes.size).to eq(0)
332
- end
333
-
334
314
  context "after it is closed" do
335
315
  before{ @queue.close }
336
316
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: agent
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.11.0
4
+ version: 0.12.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ilya Grigorik
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-03-10 00:00:00.000000000 Z
11
+ date: 2016-09-21 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rake
@@ -120,7 +120,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
120
120
  version: '0'
121
121
  requirements: []
122
122
  rubyforge_project: agent
123
- rubygems_version: 2.2.2
123
+ rubygems_version: 2.5.1
124
124
  signing_key:
125
125
  specification_version: 4
126
126
  summary: Agent is a diverse family of related approaches for modelling concurrent
@@ -145,3 +145,4 @@ test_files:
145
145
  - spec/spec_helper.rb
146
146
  - spec/uuid_spec.rb
147
147
  - spec/wait_group_spec.rb
148
+ has_rdoc: