ffi-rzmq 0.7.1 → 0.7.2

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,13 @@
1
+ == 0.7.2 / 20110224
2
+ * Several minor refactorings to make the code intent clearer and to allow
3
+ for better testing. In particular, the error condition checking for
4
+ a non-blocking send/recv is much clearer.
5
+
1
6
  == 0.7.1 / 20110130
2
7
  * Fixed 1.9.1 Binary Encoding bug when UTF8 set as default (Thanks schmurfy)
3
8
  * Improved rubinius compat for specs
4
9
  * Improved spec compatibility on linux
10
+
5
11
  == 0.7.0 / 20101222
6
12
  * Improved performance of calls to Socket#getsockopt. There are usually
7
13
  a lot of calls passing RCVMORE, so we now cache those buffers instead
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'ffi-rzmq'
3
3
 
4
4
 
5
- link = "tcp://127.0.0.1:5555"
5
+ link = "tcp://127.0.0.1:5554"
6
6
 
7
7
  ctx = ZMQ::Context.new 1
8
8
  s1 = ctx.socket ZMQ::REQ
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{ffi-rzmq}
5
- s.version = "0.7.1"
5
+ s.version = "0.7.2"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Chuck Remes"]
@@ -65,7 +65,7 @@ module ZMQ
65
65
  # Does not raise any exceptions.
66
66
  #
67
67
  def register sock, events = ZMQ::POLLIN | ZMQ::POLLOUT, fd = 0
68
- return unless sock || !fd.zero? || !events.zero?
68
+ return false if (sock.nil? && fd.zero?) || events.zero?
69
69
 
70
70
  @poll_items_dirty = true
71
71
  item = @items.get(@sockets.index(sock))
@@ -74,8 +74,7 @@ module ZMQ
74
74
  @sockets << sock
75
75
  item = LibZMQ::PollItem.new
76
76
 
77
- case sock
78
- when ZMQ::Socket, Socket
77
+ if sock.kind_of?(ZMQ::Socket) || sock.kind_of?(Socket)
79
78
  item[:socket] = sock.socket
80
79
  item[:fd] = 0
81
80
  else
@@ -134,11 +133,13 @@ module ZMQ
134
133
  # Deletes the +sock+ for all subscribed events.
135
134
  #
136
135
  def delete sock
136
+ removed = false
137
+
137
138
  if index = @sockets.index(sock)
138
- @items.delete_at index
139
- @sockets.delete sock
140
- @raw_to_socket.delete sock.socket
139
+ removed = @items.delete_at(index) and @sockets.delete(sock) and @raw_to_socket.delete(sock.socket.address)
141
140
  end
141
+
142
+ removed
142
143
  end
143
144
 
144
145
  def size(); @items.size; end
@@ -38,11 +38,14 @@ module ZMQ
38
38
  alias :push :<<
39
39
 
40
40
  def delete_at index
41
+ value = nil
41
42
  unless @items.empty?
42
- @items.delete_at index
43
+ value = @items.delete_at index
43
44
  @dirty = true
44
45
  clean
45
46
  end
47
+
48
+ value
46
49
  end
47
50
 
48
51
  def each &blk
@@ -348,11 +348,19 @@ module ZMQ
348
348
  end
349
349
 
350
350
  private
351
+
352
+ def noblock? flag
353
+ (NOBLOCK & flag) == NOBLOCK
354
+ end
351
355
 
352
356
  def _recv message, flags = 0
353
357
  result_code = LibZMQ.zmq_recv @socket, message.address, flags
354
358
 
355
- flags != NOBLOCK ? error_check(ZMQ_RECV_STR, result_code) : error_check_nonblock(result_code)
359
+ if noblock?(flags)
360
+ error_check_nonblock(result_code)
361
+ else
362
+ error_check(ZMQ_RECV_STR, result_code)
363
+ end
356
364
  end
357
365
 
358
366
  # Calls to ZMQ.getsockopt require us to pass in some pointers. We can cache and save those buffers
@@ -158,7 +158,15 @@ module ZMQ
158
158
  # send/recv. True only when #errno is EGAIN and +result_code+ is non-zero.
159
159
  #
160
160
  def error_check_nonblock result_code
161
- !result_code.zero? && eagain? ? false : true
161
+ if result_code.zero?
162
+ true
163
+ else
164
+ # need to check result_code again because !eagain? could be true
165
+ # and we need the result_code test to fail again to give the right result
166
+ # !eagain? is true, result_code is -1 => return false
167
+ # !eagain? is false, result_code is -1 => return false
168
+ !eagain? && result_code.zero?
169
+ end
162
170
  end
163
171
 
164
172
  def raise_error source, result_code
@@ -60,10 +60,12 @@ module ZMQ
60
60
 
61
61
 
62
62
  context "when allocating a socket" do
63
- it "should return a ZMQ::Socket" do
64
- ctx = spec_ctx
65
- ctx.socket(ZMQ::REQ).should be_kind_of(ZMQ::Socket)
66
- end
63
+ # it "should return a ZMQ::Socket" do
64
+ # ctx = spec_ctx
65
+ # sock = ctx.socket ZMQ::REQ
66
+ # sock.should be_kind_of(ZMQ::Socket)
67
+ # # need to do something with the socket so it's in a state that can return ETERM
68
+ # end
67
69
 
68
70
  it "should raise a ZMQ::SocketError exception when allocation fails" do
69
71
  ctx = spec_ctx
@@ -1 +1 @@
1
- 0.7.1
1
+ 0.7.2
metadata CHANGED
@@ -1,29 +1,39 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: ffi-rzmq
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.7.1
4
+ hash: 7
5
+ prerelease: false
6
+ segments:
7
+ - 0
8
+ - 7
9
+ - 2
10
+ version: 0.7.2
6
11
  platform: ruby
7
12
  authors:
8
- - Chuck Remes
13
+ - Chuck Remes
9
14
  autorequire:
10
15
  bindir: bin
11
16
  cert_chain: []
12
17
 
13
- date: 2011-01-30 00:00:00 -08:00
18
+ date: 2011-01-30 00:00:00 -06:00
14
19
  default_executable:
15
20
  dependencies:
16
- - !ruby/object:Gem::Dependency
17
- name: bones
18
- prerelease: false
19
- requirement: &id001 !ruby/object:Gem::Requirement
20
- none: false
21
- requirements:
22
- - - ">="
23
- - !ruby/object:Gem::Version
24
- version: 3.6.2
25
- type: :development
26
- version_requirements: *id001
21
+ - !ruby/object:Gem::Dependency
22
+ name: bones
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ hash: 27
30
+ segments:
31
+ - 3
32
+ - 5
33
+ - 4
34
+ version: 3.5.4
35
+ type: :development
36
+ version_requirements: *id001
27
37
  description: |-
28
38
  This gem wraps the ZeroMQ networking library using the ruby FFI (foreign
29
39
  function interface). It's a pure ruby wrapper so this gem can be loaded
@@ -42,69 +52,75 @@ executables: []
42
52
  extensions: []
43
53
 
44
54
  extra_rdoc_files:
45
- - History.txt
46
- - README.rdoc
47
- - examples/README.rdoc
55
+ - History.txt
56
+ - README.rdoc
57
+ - examples/README.rdoc
58
+ - version.txt
48
59
  files:
49
- - .bnsignore
50
- - .gitignore
51
- - History.txt
52
- - README.rdoc
53
- - Rakefile
54
- - examples/README.rdoc
55
- - examples/local_lat.rb
56
- - examples/local_lat_poll.rb
57
- - examples/local_lat_zerocopy.rb
58
- - examples/local_throughput.rb
59
- - examples/publish_subscribe.rb
60
- - examples/remote_lat.rb
61
- - examples/remote_lat_zerocopy.rb
62
- - examples/remote_throughput.rb
63
- - examples/reqrep_poll.rb
64
- - examples/request_response.rb
65
- - ffi-rzmq.gemspec
66
- - lib/ffi-rzmq.rb
67
- - lib/ffi-rzmq/context.rb
68
- - lib/ffi-rzmq/exceptions.rb
69
- - lib/ffi-rzmq/message.rb
70
- - lib/ffi-rzmq/poll.rb
71
- - lib/ffi-rzmq/poll_items.rb
72
- - lib/ffi-rzmq/socket.rb
73
- - lib/ffi-rzmq/wrapper.rb
74
- - lib/ffi-rzmq/zmq.rb
75
- - spec/context_spec.rb
76
- - spec/message_spec.rb
77
- - spec/pushpull_spec.rb
78
- - spec/reqrep_spec.rb
79
- - spec/socket_spec.rb
80
- - spec/spec_helper.rb
81
- - version.txt
60
+ - .bnsignore
61
+ - History.txt
62
+ - README.rdoc
63
+ - Rakefile
64
+ - examples/README.rdoc
65
+ - examples/local_lat.rb
66
+ - examples/local_lat_poll.rb
67
+ - examples/local_lat_zerocopy.rb
68
+ - examples/local_throughput.rb
69
+ - examples/publish_subscribe.rb
70
+ - examples/remote_lat.rb
71
+ - examples/remote_lat_zerocopy.rb
72
+ - examples/remote_throughput.rb
73
+ - examples/reqrep_poll.rb
74
+ - examples/request_response.rb
75
+ - ffi-rzmq.gemspec
76
+ - lib/ffi-rzmq.rb
77
+ - lib/ffi-rzmq/context.rb
78
+ - lib/ffi-rzmq/exceptions.rb
79
+ - lib/ffi-rzmq/message.rb
80
+ - lib/ffi-rzmq/poll.rb
81
+ - lib/ffi-rzmq/poll_items.rb
82
+ - lib/ffi-rzmq/socket.rb
83
+ - lib/ffi-rzmq/wrapper.rb
84
+ - lib/ffi-rzmq/zmq.rb
85
+ - spec/context_spec.rb
86
+ - spec/message_spec.rb
87
+ - spec/pushpull_spec.rb
88
+ - spec/reqrep_spec.rb
89
+ - spec/socket_spec.rb
90
+ - spec/spec_helper.rb
91
+ - version.txt
82
92
  has_rdoc: true
83
93
  homepage: http://github.com/chuckremes/ffi-rzmq
84
94
  licenses: []
85
95
 
86
96
  post_install_message:
87
97
  rdoc_options:
88
- - --main
89
- - README.rdoc
98
+ - --main
99
+ - README.rdoc
90
100
  require_paths:
91
- - lib
101
+ - lib
92
102
  required_ruby_version: !ruby/object:Gem::Requirement
93
103
  none: false
94
104
  requirements:
95
- - - ">="
96
- - !ruby/object:Gem::Version
97
- version: "0"
105
+ - - ">="
106
+ - !ruby/object:Gem::Version
107
+ hash: 3
108
+ segments:
109
+ - 0
110
+ version: "0"
98
111
  required_rubygems_version: !ruby/object:Gem::Requirement
99
112
  none: false
100
113
  requirements:
101
- - - ">="
102
- - !ruby/object:Gem::Version
103
- version: "0"
114
+ - - ">="
115
+ - !ruby/object:Gem::Version
116
+ hash: 3
117
+ segments:
118
+ - 0
119
+ version: "0"
104
120
  requirements: []
105
121
 
106
122
  rubyforge_project: ffi-rzmq
107
- rubygems_version: 1.4.2
123
+ rubygems_version: 1.3.7
108
124
  signing_key:
109
125
  specification_version: 3
110
126
  summary: This gem wraps the ZeroMQ networking library using the ruby FFI (foreign function interface).
data/.gitignore DELETED
@@ -1,3 +0,0 @@
1
- *.rbc
2
- *.swp
3
- pkg