nanomsg 0.4.0 → 0.5.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (6) hide show
  1. checksums.yaml +4 -4
  2. data/HISTORY +4 -0
  3. data/README +5 -3
  4. data/ext/extconf.rb +5 -0
  5. data/ext/init.c +28 -13
  6. metadata +3 -4
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: cf073be2c61a88c963a9f8ef307a9998bd1b3f5b
4
- data.tar.gz: d9716565e40d9c22758359b1d23d33633ce4d36c
3
+ metadata.gz: 338cb73be8a94cc3ee3fb4627973faedae7e81f2
4
+ data.tar.gz: be4319a9d07c46bd202c91a003a690e2dcdff1b4
5
5
  SHA512:
6
- metadata.gz: c08a0c71dd600d0d173941e112274546e9ce599cebc6356c441edf6a2b3f2f84c5f0e501ccb00d2974af9d41dabdb119ec00dddcf0667b6a1d059d70e78ccacb
7
- data.tar.gz: 3b6387a060e1afc2ff6dcfeb3c2f97385498ddf6dfa731bcdcdefe4fb84de994b269e2a37a140ab08bd375f33f64dd5baa03a0b4ad4e03ce443758ba2156a1da
6
+ metadata.gz: 0a77d0a5624efb61e649bc1486766fea9e3ac1260ce23b61daabfe83b6a7b4525840669c01ff2417a6f17dae3fc80688f874ef453167cca7c7b7cc7c79f6074a
7
+ data.tar.gz: 0f2470ea6c65d1130d6cfbd965af5abecd32ea3134fa4ef9f0c4de84313e891e060d417fd73de36cbf9ac883288e759577b5bbaae809977293541323f7ad1bd8
data/HISTORY CHANGED
@@ -1,3 +1,7 @@
1
+ = 0.5 / 27Aug2015
2
+
3
+ * GVL-code is now compatible with Ruby 2.2.
4
+
1
5
  = 0.3 / 4Sept2013
2
6
 
3
7
  * Fixes GVL related blocking behaviour, recv/send will now _NOT_ consume
data/README CHANGED
@@ -42,10 +42,12 @@ SYNOPSIS
42
42
 
43
43
  STATUS
44
44
 
45
- Very early alpha, not much testing has been done. All socket types and devices
46
- should work.
45
+ Works with a range of nanomsg versions, last one verified is 0.6. Should work
46
+ for mri rubies 1.9, 2.0, 2.1, 2.2.
47
+
48
+ Beta software: If you know what you're doing, you can use this in production.
47
49
 
48
50
  LICENSE
49
51
 
50
- See file LICENSE, Copyright (c) 2013 Kaspar Schiess
52
+ See file LICENSE, Copyright (c) 2013-2015 Kaspar Schiess
51
53
 
@@ -2,4 +2,9 @@ require 'mkmf'
2
2
 
3
3
  have_library 'nanomsg'
4
4
 
5
+ # define either HAVE_RB_THREAD_CALL_WITHOUT_GVL or
6
+ # HAVE_RB_THREAD_BLOCKING_REGION. We cannot compile without atm.
7
+ have_func('rb_thread_call_without_gvl', 'ruby/thread.h')
8
+ have_func('rb_thread_blocking_region', 'ruby.h')
9
+
5
10
  create_makefile('nanomsg_ext')
data/ext/init.c CHANGED
@@ -11,6 +11,21 @@
11
11
 
12
12
  #include "constants.h"
13
13
 
14
+ /*
15
+ This API was essentially renamed in Ruby 2.2. Let's provide a small layer
16
+ that allows us to compile in both <2.2 and >=2.2 versions.
17
+ */
18
+ #if defined(HAVE_RB_THREAD_CALL_WITHOUT_GVL)
19
+ /* Ruby 2.0+ */
20
+ # include <ruby/thread.h>
21
+ # define WITHOUT_GVL(fn,a,ubf,b) \
22
+ rb_thread_call_without_gvl((fn),(a),(ubf),(b))
23
+ #elif defined(HAVE_RB_THREAD_BLOCKING_REGION)
24
+ typedef VALUE (*blocking_fn_t)(void*);
25
+ # define WITHOUT_GVL(fn,a,ubf,b) \
26
+ rb_thread_blocking_region((blocking_fn_t)(fn),(a),(ubf),(b))
27
+ #endif
28
+
14
29
  static VALUE mNanoMsg;
15
30
  static VALUE cSocket;
16
31
 
@@ -147,7 +162,7 @@ struct ioop {
147
162
  long len;
148
163
  };
149
164
 
150
- static VALUE
165
+ static void*
151
166
  sock_send_blocking(void* data)
152
167
  {
153
168
  struct ioop *pio = data;
@@ -156,7 +171,7 @@ sock_send_blocking(void* data)
156
171
  if (pio->return_code < 0)
157
172
  pio->nn_errno = nn_errno();
158
173
 
159
- return Qnil;
174
+ return (void*) 0;
160
175
  }
161
176
 
162
177
  static VALUE
@@ -168,7 +183,7 @@ sock_send(VALUE socket, VALUE buffer)
168
183
  io.buffer = StringValuePtr(buffer);
169
184
  io.len = RSTRING_LEN(buffer);
170
185
 
171
- rb_thread_blocking_region(sock_send_blocking, &io, RUBY_UBF_IO, 0);
186
+ WITHOUT_GVL(sock_send_blocking, &io, RUBY_UBF_IO, 0);
172
187
 
173
188
  if (io.return_code < 0)
174
189
  sock_raise_error(io.nn_errno);
@@ -176,7 +191,7 @@ sock_send(VALUE socket, VALUE buffer)
176
191
  return INT2NUM(io.return_code);
177
192
  }
178
193
 
179
- static VALUE
194
+ static void*
180
195
  sock_recv_blocking(void* data)
181
196
  {
182
197
  struct ioop *pio = data;
@@ -186,7 +201,7 @@ sock_recv_blocking(void* data)
186
201
  if (pio->return_code < 0)
187
202
  pio->nn_errno = nn_errno();
188
203
 
189
- return Qnil;
204
+ return (void*) 0;
190
205
  }
191
206
 
192
207
  static VALUE
@@ -197,7 +212,7 @@ sock_recv(VALUE socket)
197
212
 
198
213
  io.sock = sock_get(socket);
199
214
 
200
- rb_thread_blocking_region(sock_recv_blocking, &io, RUBY_UBF_IO, 0);
215
+ WITHOUT_GVL(sock_recv_blocking, &io, RUBY_UBF_IO, 0);
201
216
 
202
217
  if (io.return_code < 0)
203
218
  sock_raise_error(io.nn_errno);
@@ -208,7 +223,7 @@ sock_recv(VALUE socket)
208
223
  return result;
209
224
  }
210
225
 
211
- static VALUE
226
+ static void*
212
227
  sock_close_no_gvl(void* data)
213
228
  {
214
229
  struct ioop *pio = (struct ioop*) data;
@@ -217,7 +232,7 @@ sock_close_no_gvl(void* data)
217
232
  if (pio->return_code < 0)
218
233
  pio->nn_errno = nn_errno();
219
234
 
220
- return Qnil;
235
+ return (void*) 0;
221
236
  }
222
237
 
223
238
  static VALUE
@@ -229,7 +244,7 @@ sock_close(VALUE socket)
229
244
 
230
245
  // I've no idea on how to abort a close (which may block for NN_LINGER
231
246
  // seconds), so we'll be uninterruptible.
232
- rb_thread_blocking_region(sock_close_no_gvl, &io, RUBY_UBF_IO, 0);
247
+ WITHOUT_GVL(sock_close_no_gvl, &io, RUBY_UBF_IO, 0);
233
248
 
234
249
  if (io.return_code < 0)
235
250
  sock_raise_error(io.nn_errno);
@@ -379,14 +394,14 @@ struct device_op {
379
394
  int err;
380
395
  };
381
396
 
382
- static VALUE
397
+ static void*
383
398
  nanomsg_run_device_no_gvl(void* data)
384
399
  {
385
400
  struct device_op *pop = (struct device_op*) data;
386
401
 
387
402
  pop->err = nn_device(pop->sa, pop->sb);
388
403
 
389
- return Qnil;
404
+ return (void*) 0;
390
405
  }
391
406
 
392
407
  static VALUE
@@ -397,7 +412,7 @@ nanomsg_run_device(VALUE self, VALUE a, VALUE b)
397
412
  dop.sa = sock_get(a);
398
413
  dop.sb = sock_get(b);
399
414
 
400
- rb_thread_blocking_region(nanomsg_run_device_no_gvl, &dop, RUBY_UBF_IO, 0);
415
+ WITHOUT_GVL(nanomsg_run_device_no_gvl, &dop, RUBY_UBF_IO, 0);
401
416
  if (dop.err < 0)
402
417
  RAISE_SOCK_ERROR;
403
418
 
@@ -412,7 +427,7 @@ nanomsg_run_loopback(VALUE self, VALUE a)
412
427
  dop.sa = sock_get(a);
413
428
  dop.sb = -1; // invalid socket, see documentation
414
429
 
415
- rb_thread_blocking_region(nanomsg_run_device_no_gvl, &dop, RUBY_UBF_IO, 0);
430
+ WITHOUT_GVL(nanomsg_run_device_no_gvl, &dop, RUBY_UBF_IO, 0);
416
431
  if (dop.err < 0)
417
432
  RAISE_SOCK_ERROR;
418
433
 
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: nanomsg
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.0
4
+ version: 0.5.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Kaspar Schiess
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-05-11 00:00:00.000000000 Z
11
+ date: 2015-08-27 00:00:00.000000000 Z
12
12
  dependencies: []
13
13
  description: " nanomsg library is a high-performance implementation of several
14
14
  \"scalability \n protocols\". Scalability protocol's job is to define how multiple
@@ -66,10 +66,9 @@ required_rubygems_version: !ruby/object:Gem::Requirement
66
66
  version: '0'
67
67
  requirements: []
68
68
  rubyforge_project:
69
- rubygems_version: 2.2.2
69
+ rubygems_version: 2.4.5
70
70
  signing_key:
71
71
  specification_version: 4
72
72
  summary: Ruby binding for nanomsg. nanomsg library is a high-performance implementation
73
73
  of several "scalability protocols".
74
74
  test_files: []
75
- has_rdoc: