nanomsg 0.4.0 → 0.5.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/HISTORY +4 -0
- data/README +5 -3
- data/ext/extconf.rb +5 -0
- data/ext/init.c +28 -13
- metadata +3 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 338cb73be8a94cc3ee3fb4627973faedae7e81f2
|
4
|
+
data.tar.gz: be4319a9d07c46bd202c91a003a690e2dcdff1b4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 0a77d0a5624efb61e649bc1486766fea9e3ac1260ce23b61daabfe83b6a7b4525840669c01ff2417a6f17dae3fc80688f874ef453167cca7c7b7cc7c79f6074a
|
7
|
+
data.tar.gz: 0f2470ea6c65d1130d6cfbd965af5abecd32ea3134fa4ef9f0c4de84313e891e060d417fd73de36cbf9ac883288e759577b5bbaae809977293541323f7ad1bd8
|
data/HISTORY
CHANGED
data/README
CHANGED
@@ -42,10 +42,12 @@ SYNOPSIS
|
|
42
42
|
|
43
43
|
STATUS
|
44
44
|
|
45
|
-
|
46
|
-
|
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
|
|
data/ext/extconf.rb
CHANGED
@@ -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
|
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
|
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
|
-
|
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
|
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
|
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
|
-
|
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
|
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
|
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
|
-
|
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
|
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
|
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
|
-
|
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
|
-
|
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
|
+
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-
|
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.
|
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:
|