celluloid-zmq 0.7.0 → 0.8.0

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGES.md CHANGED
@@ -1,3 +1,7 @@
1
+ 0.8.0
2
+ -----
3
+ * Update to match internals of celluloid-io
4
+
1
5
  0.7.0
2
6
  -----
3
7
  * Use celluloid-io gem
@@ -11,8 +11,8 @@ Gem::Specification.new do |gem|
11
11
  gem.name = "celluloid-zmq"
12
12
  gem.version = Celluloid::ZMQ::VERSION
13
13
 
14
- gem.add_dependency "celluloid", ">= 0.7.0"
15
- gem.add_dependency "celluloid-io", ">= 0.7.0"
14
+ gem.add_dependency "celluloid", "~> 0.8.0"
15
+ gem.add_dependency "celluloid-io", "~> 0.8.0"
16
16
  gem.add_dependency "ffi"
17
17
  gem.add_dependency "ffi-rzmq"
18
18
 
data/lib/celluloid/zmq.rb CHANGED
@@ -24,15 +24,10 @@ module Celluloid
24
24
  end
25
25
  end
26
26
 
27
- # Wait for the given IO object to become readable
28
- def wait_readable(socket)
29
- # Law of demeter be damned!
30
- current_actor.mailbox.reactor.wait_readable(socket)
31
- end
27
+ extend Forwardable
32
28
 
33
- # Wait for the given IO object to become writeable
34
- def wait_writeable(socket)
35
- current_actor.mailbox.reactor.wait_writeable(socket)
36
- end
29
+ # Wait for the given IO object to become readable/writeable
30
+ def_delegators 'current_actor.mailbox.reactor',
31
+ :wait_readable, :wait_writeable
37
32
  end
38
33
  end
@@ -6,8 +6,7 @@ module Celluloid
6
6
  # More APIs and less monkeypatching would be useful here
7
7
  @messages = []
8
8
  @lock = Mutex.new
9
- @waker = Waker.new
10
- @reactor = Reactor.new(@waker)
9
+ @reactor = Reactor.new
11
10
  end
12
11
  end
13
12
  end
@@ -3,8 +3,13 @@ module Celluloid
3
3
  # React to incoming 0MQ and Celluloid events. This is kinda sorta supposed
4
4
  # to resemble the Reactor design pattern.
5
5
  class Reactor
6
- def initialize(waker)
7
- @waker = waker
6
+ extend Forwardable
7
+
8
+ def_delegator :@waker, :signal, :wakeup
9
+ def_delegator :@waker, :cleanup, :shutdown
10
+
11
+ def initialize
12
+ @waker = Waker.new
8
13
  @poller = ::ZMQ::Poller.new
9
14
  @readers = {}
10
15
  @writers = {}
@@ -30,13 +35,12 @@ module Celluloid
30
35
  if set.has_key? socket
31
36
  raise ArgumentError, "another method is already waiting on #{socket.inspect}"
32
37
  else
33
- set[socket] = Fiber.current
38
+ set[socket] = Task.current
34
39
  end
35
40
 
36
41
  @poller.register socket, type
37
- Fiber.yield
38
42
 
39
- @poller.deregister socket, type
43
+ Task.suspend :zmqwait
40
44
  socket
41
45
  end
42
46
 
@@ -57,16 +61,28 @@ module Celluloid
57
61
 
58
62
  @poller.readables.each do |sock|
59
63
  if sock == @waker.socket
60
- yield
64
+ @waker.wait
61
65
  else
62
- fiber = @readers.delete sock
63
- fiber.resume if fiber
66
+ task = @readers.delete sock
67
+ @poller.deregister sock, ::ZMQ::POLLIN
68
+
69
+ if task
70
+ task.resume
71
+ else
72
+ Celluloid::Logger.debug "ZMQ error: got read event without associated reader"
73
+ end
64
74
  end
65
75
  end
66
76
 
67
77
  @poller.writables.each do |sock|
68
- fiber = @writers.delete sock
69
- fiber.resume if fiber
78
+ task = @writers.delete sock
79
+ @poller.deregister sock, ::ZMQ::POLLOUT
80
+
81
+ if task
82
+ task.resume
83
+ else
84
+ Celluloid::Logger.debug "ZMQ error: got write event without associated reader"
85
+ end
70
86
  end
71
87
  end
72
88
  end
@@ -1,5 +1,5 @@
1
1
  module Celluloid
2
2
  module ZMQ
3
- VERSION = "0.7.0"
3
+ VERSION = "0.8.0"
4
4
  end
5
5
  end
@@ -1,6 +1,7 @@
1
1
  module Celluloid
2
2
  module ZMQ
3
- class DeadWakerError < Celluloid::IO::DeadWakerError; end # You can't wake the dead
3
+ # You can't wake the dead
4
+ DeadWakerError = Class.new IOError
4
5
 
5
6
  # Wakes up sleepy threads so that they can check their mailbox
6
7
  # Works like a ConditionVariable, except it's implemented as a ZMQ socket
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: celluloid-zmq
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.7.0
4
+ version: 0.8.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,33 +9,33 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-12-29 00:00:00.000000000 Z
12
+ date: 2012-01-24 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: celluloid
16
- requirement: &70174602938680 !ruby/object:Gem::Requirement
16
+ requirement: &70168804718540 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
- - - ! '>='
19
+ - - ~>
20
20
  - !ruby/object:Gem::Version
21
- version: 0.7.0
21
+ version: 0.8.0
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70174602938680
24
+ version_requirements: *70168804718540
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: celluloid-io
27
- requirement: &70174602938180 !ruby/object:Gem::Requirement
27
+ requirement: &70168804717900 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
- - - ! '>='
30
+ - - ~>
31
31
  - !ruby/object:Gem::Version
32
- version: 0.7.0
32
+ version: 0.8.0
33
33
  type: :runtime
34
34
  prerelease: false
35
- version_requirements: *70174602938180
35
+ version_requirements: *70168804717900
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: ffi
38
- requirement: &70174602937780 !ruby/object:Gem::Requirement
38
+ requirement: &70168804717360 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,10 @@ dependencies:
43
43
  version: '0'
44
44
  type: :runtime
45
45
  prerelease: false
46
- version_requirements: *70174602937780
46
+ version_requirements: *70168804717360
47
47
  - !ruby/object:Gem::Dependency
48
48
  name: ffi-rzmq
49
- requirement: &70174602937280 !ruby/object:Gem::Requirement
49
+ requirement: &70168804716260 !ruby/object:Gem::Requirement
50
50
  none: false
51
51
  requirements:
52
52
  - - ! '>='
@@ -54,10 +54,10 @@ dependencies:
54
54
  version: '0'
55
55
  type: :runtime
56
56
  prerelease: false
57
- version_requirements: *70174602937280
57
+ version_requirements: *70168804716260
58
58
  - !ruby/object:Gem::Dependency
59
59
  name: rake
60
- requirement: &70174602936840 !ruby/object:Gem::Requirement
60
+ requirement: &70168804715840 !ruby/object:Gem::Requirement
61
61
  none: false
62
62
  requirements:
63
63
  - - ! '>='
@@ -65,10 +65,10 @@ dependencies:
65
65
  version: '0'
66
66
  type: :development
67
67
  prerelease: false
68
- version_requirements: *70174602936840
68
+ version_requirements: *70168804715840
69
69
  - !ruby/object:Gem::Dependency
70
70
  name: rspec
71
- requirement: &70174602936280 !ruby/object:Gem::Requirement
71
+ requirement: &70168804715220 !ruby/object:Gem::Requirement
72
72
  none: false
73
73
  requirements:
74
74
  - - ! '>='
@@ -76,7 +76,7 @@ dependencies:
76
76
  version: 2.7.0
77
77
  type: :development
78
78
  prerelease: false
79
- version_requirements: *70174602936280
79
+ version_requirements: *70168804715220
80
80
  description: Celluloid bindings to the ffi-rzmq library
81
81
  email:
82
82
  - tony.arcieri@gmail.com
@@ -93,6 +93,7 @@ files:
93
93
  - lib/celluloid/zmq/waker.rb
94
94
  - lib/celluloid/zmq.rb
95
95
  - pkg/celluloid-zmq-0.0.4.gem
96
+ - pkg/celluloid-zmq-0.7.0.gem
96
97
  - Rakefile
97
98
  - README.md
98
99
  - spec/celluloid/zmq/actor_spec.rb
@@ -129,3 +130,4 @@ test_files:
129
130
  - spec/celluloid/zmq/mailbox_spec.rb
130
131
  - spec/spec_helper.rb
131
132
  - .gitignore
133
+ has_rdoc: