uringmachine 0.28.2 → 0.28.3

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: 21a7c3c4503c06967ae77b6b3c8da3fb0f19eae3373efccb018ff111dc6d2aa8
4
- data.tar.gz: 5376adb14245278692e634fdb6843080239a7a806b13032706b91036a9483c1a
3
+ metadata.gz: fbdc1ca412e20436a209c2e4f77af29873d5c8bac02f88c35562333f1e5328e6
4
+ data.tar.gz: d426661ce83c278041042c5829a23b4bb5c0c65cf99d1cb3cb96f5706b464859
5
5
  SHA512:
6
- metadata.gz: 0b00614b471f51e8c3e31c77b2844284c371a4c0a73b30c0016969421ee20777ce2ca5ee215201a1a31aec189f7f703f39a0884c262c3ffc5c36ccbbae73a6f1
7
- data.tar.gz: 26efdd3e98c013e9edd0962cc0fcab3bd9454485743fabc05a1d181200ad256aeb649618193048451850b39623f48cd69e9563f21defb8a178c5dcc300f24eb5
6
+ metadata.gz: 9908398a698bf7a2771a88b369023e27c3669bd205eb86a8132fee154709d68b21cd05a4fcd8b0bacb0f8e10140f2a2ef002f01cd7ac8177bf678c4f8e8574b5
7
+ data.tar.gz: afb606febf25d41fdf99b00e8cdeaa97523608445cc842cf49acbdf5af95f726276d443a574363b23b9b6c8287fad560780913f4bf1fd09240cf5df29185a9ac
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ # 0.28.3 2026-02-22
2
+
3
+ - Accept array in `#terminate` and `#join`
4
+
1
5
  # 0.28.2 2026-02-20
2
6
 
3
7
  - Fix `Stream#get_string`
data/TODO.md CHANGED
@@ -1,5 +1,25 @@
1
1
  ## immediate
2
2
 
3
+ - Add support for exception instances in `#timeout`.
4
+ - Add support for returning a value on timeout:
5
+
6
+ Since to do this safely we need to actually raise an exception that wraps the
7
+ value, rescue it and return the value, we might want a separate method that
8
+ wraps `#timeout`:
9
+
10
+ ```ruby
11
+ TimeoutValueError < StandardError
12
+
13
+ def timeout_with_value(interval, value, &block)
14
+ timeout_error = TimeoutValueError
15
+ timeout(interval, timeout_error, &block)
16
+ rescue TimeoutValueError => e
17
+ raise if e != timeout_error
18
+
19
+ value
20
+ end
21
+ ```
22
+
3
23
  - Add tests for support for Set in `machine#await_fibers`
4
24
  - Add tests for support for Set, Array in `machine#join`
5
25
  - Add `#read_file` for reading entire file
@@ -145,3 +165,14 @@ jobs = (1..100).map { |i|
145
165
  }
146
166
  machine.join(jobs)
147
167
  ```
168
+
169
+ ## Other abstractions
170
+
171
+ - Happy eyeballs connect
172
+
173
+ ```ruby
174
+ # addrs: [['1.1.1.1', 80], ['2.2.2.2', 80]]
175
+ # ['1.1.1.1:80', '2.2.2.2:80']
176
+ tcp_connect_happy_eyeballs(*addrs)
177
+ ```
178
+
data/ext/um/um.c CHANGED
@@ -539,7 +539,7 @@ VALUE um_timeout_complete(VALUE arg) {
539
539
 
540
540
  VALUE um_timeout(struct um *machine, VALUE interval, VALUE class) {
541
541
  static ID ID_new = 0;
542
- if (!ID_new) ID_new = rb_intern("new");
542
+ if (unlikely(!ID_new)) ID_new = rb_intern("new");
543
543
 
544
544
  struct um_op *op = um_op_acquire(machine);
545
545
  um_prep_op(machine, op, OP_TIMEOUT, 2, 0);
@@ -1,5 +1,5 @@
1
1
  # frozen_string_literal: true
2
2
 
3
3
  class UringMachine
4
- VERSION = '0.28.2'
4
+ VERSION = '0.28.3'
5
5
  end
data/lib/uringmachine.rb CHANGED
@@ -36,9 +36,17 @@ class UringMachine
36
36
  fiber
37
37
  end
38
38
 
39
+ TERMINATE_EXCEPTION = UM::Terminate.new
40
+
41
+ # Terminates the given fibers by scheduling them with a `UM::Terminate`
42
+ # exception. This method does not wait for the fibers to be done.
43
+ #
44
+ # @param *fibers [Array<Fiber>] fibers to terminate
45
+ # @return [void]
39
46
  def terminate(*fibers)
40
- exception = UM::Terminate.new
41
- fibers.each { schedule(it, exception) }
47
+ fibers = fibers.first if fibers.size == 1 && fibers.first.is_a?(Enumerable)
48
+
49
+ fibers.each { schedule(it, TERMINATE_EXCEPTION) }
42
50
  end
43
51
 
44
52
  # Runs the given block in the given fiber. This method is used to run fibers
@@ -58,6 +66,8 @@ class UringMachine
58
66
  #
59
67
  # @return [Array<any>] return values of the given fibers
60
68
  def join(*fibers)
69
+ fibers = fibers.first if fibers.size == 1 && fibers.first.is_a?(Enumerable)
70
+
61
71
  results = fibers.inject({}) { |h, f| h[f] = nil; h }
62
72
  queue = nil
63
73
  pending = nil
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.2
4
+ version: 0.28.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sharon Rosner