polyphony 0.92 → 0.93
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 +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/Rakefile +1 -1
- data/ext/polyphony/backend_common.c +17 -1
- data/ext/polyphony/backend_common.h +1 -1
- data/ext/polyphony/backend_io_uring.c +5 -5
- data/ext/polyphony/backend_libev.c +3 -3
- data/ext/polyphony/extconf.rb +4 -0
- data/lib/polyphony/version.rb +1 -1
- data/test/test_backend.rb +17 -0
- metadata +7 -7
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: bb7ee7e43bec0bfffbcff8c78cdcdcc7d93f4283014bd9caebfcd94c3da6b96f
|
4
|
+
data.tar.gz: add731011308495bc5ec0f4f5bc1f7152cfaa1dddd0f53f8027b4a64ea0ba08f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 108f69257c57caab18780bad60dbd6bed240dd8a45e05e54e54cbb4b90d31382c10c8f25d3c8bb92f8753e134054782eb4b9d47e79ec79da8938ac4c3d14f4a6
|
7
|
+
data.tar.gz: be78ce7748655d18014074fbb95bedecccab8af94b53e7a2db797cdb503a4f67c25a81b9e9b9154d6e1187efbc3c5fd1b4454e604ad068d51a0c3f411ee7c8ea
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/Rakefile
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
#include "ruby/io.h"
|
5
5
|
#include "polyphony.h"
|
6
6
|
#include "backend_common.h"
|
7
|
+
#ifdef HAVE_RUBY_IO_BUFFER_H
|
8
|
+
#include "ruby/io/buffer.h"
|
9
|
+
#endif
|
7
10
|
|
8
11
|
inline void backend_base_initialize(struct Backend_base *base) {
|
9
12
|
runqueue_initialize(&base->runqueue);
|
@@ -476,11 +479,24 @@ int backend_getaddrinfo(VALUE host, VALUE port, struct sockaddr **ai_addr) {
|
|
476
479
|
return addrinfo_result->ai_addrlen;
|
477
480
|
}
|
478
481
|
|
479
|
-
struct io_buffer get_io_buffer(VALUE in) {
|
482
|
+
struct io_buffer get_io_buffer(VALUE in, int rw) {
|
480
483
|
if (FIXNUM_P(in)) {
|
481
484
|
struct raw_buffer *raw = FIX2PTR(in);
|
482
485
|
return (struct io_buffer){ raw->ptr, raw->len, 1 };
|
483
486
|
}
|
487
|
+
|
488
|
+
#ifdef HAVE_RUBY_IO_BUFFER_H
|
489
|
+
if (rb_obj_is_kind_of(in, rb_cIOBuffer) == Qtrue) {
|
490
|
+
void *ptr;
|
491
|
+
size_t len;
|
492
|
+
if (rw)
|
493
|
+
rb_io_buffer_get_bytes_for_reading(in, (const void **)&ptr, &len);
|
494
|
+
else
|
495
|
+
rb_io_buffer_get_bytes_for_writing(in, &ptr, &len);
|
496
|
+
return (struct io_buffer){ ptr, len, 1 };
|
497
|
+
}
|
498
|
+
#endif
|
499
|
+
|
484
500
|
return (struct io_buffer){ (unsigned char *)RSTRING_PTR(in), RSTRING_LEN(in), 0 };
|
485
501
|
}
|
486
502
|
|
@@ -71,7 +71,7 @@ struct io_buffer {
|
|
71
71
|
#define FIX2PTR(v) ((void *)(FIX2LONG(v)))
|
72
72
|
#define PTR2FIX(p) LONG2FIX((long)p)
|
73
73
|
|
74
|
-
struct io_buffer get_io_buffer(VALUE in);
|
74
|
+
struct io_buffer get_io_buffer(VALUE in, int rw);
|
75
75
|
VALUE coerce_io_string_or_buffer(VALUE buf);
|
76
76
|
|
77
77
|
#ifdef POLYPHONY_USE_PIDFD_OPEN
|
@@ -363,7 +363,7 @@ VALUE Backend_read(VALUE self, VALUE io, VALUE str, VALUE length, VALUE to_eof,
|
|
363
363
|
Backend_t *backend;
|
364
364
|
int fd;
|
365
365
|
rb_io_t *fptr;
|
366
|
-
struct io_buffer buffer = get_io_buffer(str);
|
366
|
+
struct io_buffer buffer = get_io_buffer(str, 0);
|
367
367
|
long buf_pos = FIX2INT(pos);
|
368
368
|
int shrinkable_string = 0;
|
369
369
|
int expandable_buffer = 0;
|
@@ -552,7 +552,7 @@ VALUE Backend_write(VALUE self, VALUE io, VALUE str) {
|
|
552
552
|
int fd;
|
553
553
|
rb_io_t *fptr;
|
554
554
|
|
555
|
-
struct io_buffer buffer = get_io_buffer(str);
|
555
|
+
struct io_buffer buffer = get_io_buffer(str, 1);
|
556
556
|
long left = buffer.len;
|
557
557
|
|
558
558
|
GetBackend(self, backend);
|
@@ -668,7 +668,7 @@ VALUE Backend_recv(VALUE self, VALUE io, VALUE str, VALUE length, VALUE pos) {
|
|
668
668
|
Backend_t *backend;
|
669
669
|
int fd;
|
670
670
|
rb_io_t *fptr;
|
671
|
-
struct io_buffer buffer = get_io_buffer(str);
|
671
|
+
struct io_buffer buffer = get_io_buffer(str, 0);
|
672
672
|
long buf_pos = FIX2INT(pos);
|
673
673
|
int shrinkable_string = 0;
|
674
674
|
int expandable_buffer = 0;
|
@@ -836,7 +836,7 @@ VALUE Backend_send(VALUE self, VALUE io, VALUE str, VALUE flags) {
|
|
836
836
|
int fd;
|
837
837
|
rb_io_t *fptr;
|
838
838
|
|
839
|
-
struct io_buffer buffer = get_io_buffer(str);
|
839
|
+
struct io_buffer buffer = get_io_buffer(str, 1);
|
840
840
|
long left = buffer.len;
|
841
841
|
int flags_int = FIX2INT(flags);
|
842
842
|
|
@@ -1075,7 +1075,7 @@ VALUE double_splice_cleanup(struct double_splice_ctx *ctx) {
|
|
1075
1075
|
}
|
1076
1076
|
|
1077
1077
|
VALUE Backend_double_splice(VALUE self, VALUE src, VALUE dest) {
|
1078
|
-
struct double_splice_ctx ctx = { NULL, src, dest, 0, 0 };
|
1078
|
+
struct double_splice_ctx ctx = { NULL, src, dest, {0, 0} };
|
1079
1079
|
GetBackend(self, ctx.backend);
|
1080
1080
|
if (pipe(ctx.pipefd) == -1) rb_syserr_fail(errno, strerror(errno));
|
1081
1081
|
|
@@ -290,7 +290,7 @@ VALUE Backend_read(VALUE self, VALUE io, VALUE str, VALUE length, VALUE to_eof,
|
|
290
290
|
int fd;
|
291
291
|
rb_io_t *fptr;
|
292
292
|
|
293
|
-
struct io_buffer buffer = get_io_buffer(str);
|
293
|
+
struct io_buffer buffer = get_io_buffer(str, 0);
|
294
294
|
long buf_pos = FIX2INT(pos);
|
295
295
|
int shrinkable_string = 0;
|
296
296
|
int expandable_buffer = 0;
|
@@ -486,7 +486,7 @@ VALUE Backend_write(VALUE self, VALUE io, VALUE str) {
|
|
486
486
|
rb_io_t *fptr;
|
487
487
|
VALUE switchpoint_result = Qnil;
|
488
488
|
|
489
|
-
struct io_buffer buffer = get_io_buffer(str);
|
489
|
+
struct io_buffer buffer = get_io_buffer(str, 1);
|
490
490
|
long left = buffer.len;
|
491
491
|
|
492
492
|
GetBackend(self, backend);
|
@@ -761,7 +761,7 @@ VALUE Backend_send(VALUE self, VALUE io, VALUE str, VALUE flags) {
|
|
761
761
|
rb_io_t *fptr;
|
762
762
|
VALUE switchpoint_result = Qnil;
|
763
763
|
|
764
|
-
struct io_buffer buffer = get_io_buffer(str);
|
764
|
+
struct io_buffer buffer = get_io_buffer(str, 1);
|
765
765
|
long left = buffer.len;
|
766
766
|
int flags_int = FIX2INT(flags);
|
767
767
|
|
data/ext/polyphony/extconf.rb
CHANGED
@@ -61,6 +61,8 @@ else
|
|
61
61
|
$defs << '-DEV_USE_PORT' if have_type('port_event_t', 'port.h')
|
62
62
|
$defs << '-DHAVE_SYS_RESOURCE_H' if have_header('sys/resource.h')
|
63
63
|
|
64
|
+
$defs << "-DEV_STANDALONE" # prevent libev from assuming "config.h" exists
|
65
|
+
|
64
66
|
$CFLAGS << " -Wno-comment"
|
65
67
|
$CFLAGS << " -Wno-unused-result"
|
66
68
|
$CFLAGS << " -Wno-dangling-else"
|
@@ -75,4 +77,6 @@ if RUBY_VERSION >= '3.1'
|
|
75
77
|
have_func('rb_fiber_transfer', 'ruby.h')
|
76
78
|
end
|
77
79
|
|
80
|
+
have_header('ruby/io/buffer.h')
|
81
|
+
|
78
82
|
create_makefile 'polyphony_ext'
|
data/lib/polyphony/version.rb
CHANGED
data/test/test_backend.rb
CHANGED
@@ -404,6 +404,23 @@ class BackendTest < MiniTest::Test
|
|
404
404
|
sleep 0.01
|
405
405
|
assert_equal 2, counter
|
406
406
|
end
|
407
|
+
|
408
|
+
def test_read_write_with_io_buffer
|
409
|
+
skip "Works only on Ruby >= 3.1" if RUBY_VERSION < '3.1'
|
410
|
+
|
411
|
+
msg = 'Hello world'
|
412
|
+
i, o = IO.pipe
|
413
|
+
read_buffer = IO::Buffer.new(64)
|
414
|
+
f = spin { @backend.read(i, read_buffer, 64, true, 0) }
|
415
|
+
write_buffer = IO::Buffer.new(msg.bytesize)
|
416
|
+
write_buffer.set_string(msg, 0)
|
417
|
+
@backend.write(o, write_buffer)
|
418
|
+
o.close
|
419
|
+
return_value = f.await
|
420
|
+
|
421
|
+
assert_equal msg.bytesize, return_value
|
422
|
+
assert_equal msg, read_buffer.get_string(0, msg.bytesize)
|
423
|
+
end
|
407
424
|
end
|
408
425
|
|
409
426
|
class BackendChainTest < MiniTest::Test
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: polyphony
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '0.
|
4
|
+
version: '0.93'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Sharon Rosner
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2022-04-
|
11
|
+
date: 2022-04-05 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake-compiler
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - "~>"
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: 1.1.4
|
139
|
-
description:
|
139
|
+
description:
|
140
140
|
email: sharon@noteflakes.com
|
141
141
|
executables: []
|
142
142
|
extensions:
|
@@ -645,7 +645,7 @@ metadata:
|
|
645
645
|
documentation_uri: https://digital-fabric.github.io/polyphony/
|
646
646
|
homepage_uri: https://digital-fabric.github.io/polyphony/
|
647
647
|
changelog_uri: https://github.com/digital-fabric/polyphony/blob/master/CHANGELOG.md
|
648
|
-
post_install_message:
|
648
|
+
post_install_message:
|
649
649
|
rdoc_options:
|
650
650
|
- "--title"
|
651
651
|
- polyphony
|
@@ -664,8 +664,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
664
664
|
- !ruby/object:Gem::Version
|
665
665
|
version: '0'
|
666
666
|
requirements: []
|
667
|
-
rubygems_version: 3.
|
668
|
-
signing_key:
|
667
|
+
rubygems_version: 3.3.3
|
668
|
+
signing_key:
|
669
669
|
specification_version: 4
|
670
670
|
summary: Fine grained concurrency for Ruby
|
671
671
|
test_files: []
|