uringmachine 0.28.0 → 0.28.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: c42e434298bf496752efc6fe6a4cc81d04857f28f1151cfc3165ac3c288ec6a2
4
- data.tar.gz: ec176b165f129aa7d1b6d0bdbc5f4b7e55d5e553569061d89956d0b1aee68503
3
+ metadata.gz: 9fb662e62914ca38e254df5ee924b61155b510d3e862efa2f2e0997b00e7b3fd
4
+ data.tar.gz: 6ea55d8b64df3873677d1243342d5d6163812068392498f1f080351d0fc9d3e2
5
5
  SHA512:
6
- metadata.gz: 1760b892d6ae21c7007fd0a109a78d631da4ae9a79667ad85bc4740ac0e339802ca9cb0bc34114570bf7e6113e4dab704a1c9f40513a196e840b759a494a35b9
7
- data.tar.gz: 7dfe1426f96ecd1e99af4224c34d3b3173858b5d6c156b949314a0e80c34b836ae738e930ed26662319bc6700401cd0b369028e172ed1b70982cee64fb13f7a1
6
+ metadata.gz: 3ca70d442ad7b7379dccb7e1e6df6acac913f2b5ae9ac9a2ca87b8ab5ecac5efd00454888921faa7960321f91493ad10dd337ab043fc3b4771fdb6bc17dead0b
7
+ data.tar.gz: 6e4102474725dc14bf91690edcaf0e53d3eb9c7796b8edd72e2ec89629b7fc2c821e2a8c1e1abfaf52f0a27d9dd8153e6b750ed3f525436162bd93db7bf5aece
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.28.1 2026-02-20
2
+
3
+ - Add `Stream#machine`, `Stream#fd`
4
+
1
5
  # 0.28.0 2026-02-19
2
6
 
3
7
  - Add `#terminate`
data/TODO.md CHANGED
@@ -2,6 +2,8 @@
2
2
 
3
3
  - Add tests for support for Set in `machine#await_fibers`
4
4
  - Add tests for support for Set, Array in `machine#join`
5
+ - Add `#read_file` for reading entire file
6
+ - Add `#write_file` for writing entire file
5
7
 
6
8
  - (?) Fix all futex value (Queue, Mutex) to be properly aligned
7
9
 
@@ -110,3 +112,36 @@ stream.read_to_eof(buf)
110
112
  # defaults:
111
113
  stream.read_to_eof(nil)
112
114
  ```
115
+
116
+ ## Syntax / pattern for launching multiple operations
117
+
118
+ ```ruby
119
+ results = machine.concurrently(
120
+ -> { machine.read(fd1, ...) },
121
+ -> { machine.read(fd2, ...) }
122
+ -> { ... }
123
+ )
124
+
125
+ # or maybe:
126
+ jobs = (1..100).map { |i| -> { machine.read_file("/file_#{i}.csv") } }
127
+ machine.join(jobs)
128
+
129
+ # or maybe:
130
+ jobs = (1..100).map { |i|
131
+ -> {
132
+ pipe { machine.read_file("/file_#{i}.csv") }
133
+ > { csv_to_pdf(it) }
134
+ > { machine.write_file("/file_#{i}.pdf", it) }
135
+ }
136
+ }
137
+
138
+ # or otherwise
139
+ jobs = (1..100).map { |i|
140
+ -> {
141
+ csv = machine.read_file("/file_#{i}.csv")
142
+ pdf = csv_to_pdf(csv)
143
+ machine.write_file("/file_#{i}.pdf", pdf)
144
+ }
145
+ }
146
+ machine.join(jobs)
147
+ ```
@@ -51,6 +51,16 @@ VALUE Stream_initialize(VALUE self, VALUE machine, VALUE fd) {
51
51
  return self;
52
52
  }
53
53
 
54
+ VALUE Stream_machine(VALUE self) {
55
+ struct um_stream *stream = Stream_data(self);
56
+ return stream->machine->self;
57
+ }
58
+
59
+ VALUE Stream_fd(VALUE self) {
60
+ struct um_stream *stream = Stream_data(self);
61
+ return ULONG2NUM(stream->fd);
62
+ }
63
+
54
64
  VALUE Stream_get_line(VALUE self, VALUE buf, VALUE limit) {
55
65
  struct um_stream *stream = Stream_data(self);
56
66
  if (unlikely(stream->eof)) return Qnil;
@@ -109,6 +119,8 @@ void Init_Stream(void) {
109
119
  rb_define_alloc_func(cStream, Stream_allocate);
110
120
 
111
121
  rb_define_method(cStream, "initialize", Stream_initialize, 2);
122
+ rb_define_method(cStream, "machine", Stream_machine, 0);
123
+ rb_define_method(cStream, "fd", Stream_fd, 0);
112
124
 
113
125
  rb_define_method(cStream, "get_line", Stream_get_line, 2);
114
126
  rb_define_method(cStream, "get_string", Stream_get_string, 2);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UringMachine
4
- VERSION = '0.28.0'
4
+ VERSION = '0.28.1'
5
5
  end
data/test/test_stream.rb CHANGED
@@ -11,6 +11,14 @@ class StreamBaseTest < UMBaseTest
11
11
  end
12
12
 
13
13
  class StreamTest < StreamBaseTest
14
+ def test_stream_machine
15
+ assert_equal @machine, @stream.machine
16
+ end
17
+
18
+ def test_stream_fd
19
+ assert_equal @rfd, @stream.fd
20
+ end
21
+
14
22
  def test_get_line
15
23
  machine.write(@wfd, "foo\nbar\r\nbaz")
16
24
  machine.close(@wfd)
data/test/test_um.rb CHANGED
@@ -2103,26 +2103,6 @@ class SendRecvFdTest < UMBaseTest
2103
2103
  machine.close(w_fd) rescue nil
2104
2104
  end
2105
2105
 
2106
- def test_send_recv_fd_fork_inverse
2107
- pid = fork do
2108
- m = UM.new
2109
- r, w = UM.pipe
2110
- m.send_fd(@s2_fd, r)
2111
-
2112
- buf = +''
2113
- m.read(r, buf, 128)
2114
- m.send(@s2_fd, buf)
2115
- end
2116
-
2117
- assert_raises(Errno::EINVAL) { machine.recv_fd(@s1_fd) }
2118
- ensure
2119
- if pid
2120
- Process.kill('KILL', pid) rescue nil
2121
- Process.wait(pid) rescue nil
2122
- end
2123
- machine.close(w) rescue nil
2124
- end
2125
-
2126
2106
  def test_send_fd_bad_sock_fd
2127
2107
  _r_fd, w_fd = UM.pipe
2128
2108
  assert_raises(Errno::ENOTSOCK) { machine.send_fd(0, w_fd) }
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: uringmachine
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.28.0
4
+ version: 0.28.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner