io-wait 0.3.0 → 0.3.2

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: 630936f8af6e2cf9265ebff0794cab1daf10048933460b71306486aecb92a85a
4
- data.tar.gz: 153bc0301fdb8fce6f4983d45879364509bb6534a81775d98e5f61b5ffe1923e
3
+ metadata.gz: '09f49ee95b2ba86480e8e9433aeb0f05890e1573b04a9967f76a705da944c11b'
4
+ data.tar.gz: 48db6154ed263ecdb3a3ace629d629c18c18637e8577cec6d784310b38e33050
5
5
  SHA512:
6
- metadata.gz: 07e0a9997d9e8dd84368feb0fdcd681282d7c583aea8d03d90abf031d6474224aa7a6f61050de11a03750cc0e20ba5759ac4eca28aae07891a778ef82cef24c6
7
- data.tar.gz: 7294e823b4536cded39faead19916b437e4a8a4d398e35917c81e84d4618d5f99bd414aa9f6989cfad4bfb8bf0721fb7934b083a72576a7e95a60d7fcf35e853
6
+ metadata.gz: 72db9c0fea93027e7c8489ad5ecc7533c99f494743939ca2a1aaac3cac3847847538e07346ae53ca9026fb20aaa801ca0d35a5e8c491047f96b1e6cea0996e92
7
+ data.tar.gz: b70fc31c4c86f82e026be29904dbb819cb45deb2b6cff8d4cde4266f039c3b3b2c64e3b6c99be9df3034f1a9b8766d87078c1e2dba379aa542e914766712f564
data/.document ADDED
@@ -0,0 +1,6 @@
1
+ COPYING
2
+ ChangeLog
3
+ README.md
4
+ _doc/
5
+ ext/
6
+ logs/ChangeLog-*
data/.rdoc_options ADDED
@@ -0,0 +1,2 @@
1
+ ---
2
+ main_page: README.md
data/Gemfile CHANGED
@@ -7,5 +7,6 @@ group :development do
7
7
  gem "rake"
8
8
  gem "rake-compiler"
9
9
  gem "test-unit"
10
+ gem "test-unit-ruby-core"
10
11
  gem 'ruby-maven', :platforms => :jruby
11
12
  end
data/_doc/io.rb ADDED
@@ -0,0 +1,3 @@
1
+ # See {IO}[https://docs.ruby-lang.org/en/master/IO.html]
2
+ class IO
3
+ end
data/ext/io/wait/depend CHANGED
@@ -2,7 +2,7 @@
2
2
  wait.o: $(RUBY_EXTCONF_H)
3
3
  wait.o: $(arch_hdrdir)/ruby/config.h
4
4
  wait.o: $(hdrdir)/ruby.h
5
- # wait.o: $(hdrdir)/ruby/assert.h # not in 2.6
5
+ wait.o: $(hdrdir)/ruby/assert.h
6
6
  wait.o: $(hdrdir)/ruby/backward.h
7
7
  wait.o: $(hdrdir)/ruby/defines.h
8
8
  wait.o: $(hdrdir)/ruby/encoding.h
@@ -1,24 +1,21 @@
1
1
  # frozen_string_literal: false
2
2
  require 'mkmf'
3
3
 
4
- if RUBY_VERSION < "2.6"
5
- File.write("Makefile", dummy_makefile($srcdir).join(""))
4
+ target = "io/wait"
5
+ have_func("rb_io_wait", "ruby/io.h")
6
+ have_func("rb_io_descriptor", "ruby/io.h")
7
+ unless macro_defined?("DOSISH", "#include <ruby.h>")
8
+ have_header(ioctl_h = "sys/ioctl.h") or ioctl_h = nil
9
+ fionread = %w[sys/ioctl.h sys/filio.h sys/socket.h].find do |h|
10
+ have_macro("FIONREAD", [h, ioctl_h].compact)
11
+ end
12
+ if fionread
13
+ $defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
14
+ create_makefile(target)
15
+ end
6
16
  else
7
- target = "io/wait"
8
- have_func("rb_io_wait")
9
- unless macro_defined?("DOSISH", "#include <ruby.h>")
10
- have_header(ioctl_h = "sys/ioctl.h") or ioctl_h = nil
11
- fionread = %w[sys/ioctl.h sys/filio.h sys/socket.h].find do |h|
12
- have_macro("FIONREAD", [h, ioctl_h].compact)
13
- end
14
- if fionread
15
- $defs << "-DFIONREAD_HEADER=\"<#{fionread}>\""
16
- create_makefile(target)
17
- end
18
- else
19
- if have_func("rb_w32_ioctlsocket", "ruby.h")
20
- have_func("rb_w32_is_socket", "ruby.h")
21
- create_makefile(target)
22
- end
17
+ if have_func("rb_w32_ioctlsocket", "ruby.h")
18
+ have_func("rb_w32_is_socket", "ruby.h")
19
+ create_makefile(target)
23
20
  end
24
21
  end
data/ext/io/wait/wait.c CHANGED
@@ -87,8 +87,15 @@ io_nread(VALUE io)
87
87
  rb_io_check_readable(fptr);
88
88
  len = rb_io_read_pending(fptr);
89
89
  if (len > 0) return INT2FIX(len);
90
- if (!FIONREAD_POSSIBLE_P(fptr->fd)) return INT2FIX(0);
91
- if (ioctl(fptr->fd, FIONREAD, &n)) return INT2FIX(0);
90
+
91
+ #ifdef HAVE_RB_IO_DESCRIPTOR
92
+ int fd = rb_io_descriptor(io);
93
+ #else
94
+ int fd = fptr->fd;
95
+ #endif
96
+
97
+ if (!FIONREAD_POSSIBLE_P(fd)) return INT2FIX(0);
98
+ if (ioctl(fd, FIONREAD, &n)) return INT2FIX(0);
92
99
  if (n > 0) return ioctl_arg2num(n);
93
100
  return INT2FIX(0);
94
101
  }
@@ -305,7 +312,7 @@ io_event_from_value(VALUE value)
305
312
  /*
306
313
  * call-seq:
307
314
  * io.wait(events, timeout) -> event mask, false or nil
308
- * io.wait(timeout = nil, mode = :read) -> self, true, or false
315
+ * io.wait(*event_symbols[, timeout]) -> self, true, or false
309
316
  *
310
317
  * Waits until the IO becomes ready for the specified events and returns the
311
318
  * subset of events that become ready, or a falsy value when times out.
@@ -313,10 +320,14 @@ io_event_from_value(VALUE value)
313
320
  * The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or
314
321
  * +IO::PRIORITY+.
315
322
  *
316
- * Returns a truthy value immediately when buffered data is available.
323
+ * Returns an event mask (truthy value) immediately when buffered data is
324
+ * available.
317
325
  *
318
- * Optional parameter +mode+ is one of +:read+, +:write+, or
319
- * +:read_write+.
326
+ * The second form: if one or more event symbols (+:read+, +:write+, or
327
+ * +:read_write+) are passed, the event mask is the bit OR of the bitmask
328
+ * corresponding to those symbols. In this form, +timeout+ is optional, the
329
+ * order of the arguments is arbitrary, and returns +io+ if any of the
330
+ * events is ready.
320
331
  *
321
332
  * You must require 'io/wait' to use this method.
322
333
  */
@@ -353,10 +364,6 @@ io_wait(int argc, VALUE *argv, VALUE io)
353
364
  rb_io_event_t events = 0;
354
365
  int i, return_io = 0;
355
366
 
356
- /* The documented signature for this method is actually incorrect.
357
- * A single timeout is allowed in any position, and multiple symbols can be given.
358
- * Whether this is intentional or not, I don't know, and as such I consider this to
359
- * be a legacy/slow path. */
360
367
  if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) {
361
368
  /* We'd prefer to return the actual mask, but this form would return the io itself: */
362
369
  return_io = 1;
metadata CHANGED
@@ -1,15 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-wait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.0
4
+ version: 0.3.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
8
  - Charles Oliver Nutter
9
- autorequire:
10
9
  bindir: exe
11
10
  cert_chain: []
12
- date: 2022-12-16 00:00:00.000000000 Z
11
+ date: 2025-07-15 00:00:00.000000000 Z
13
12
  dependencies: []
14
13
  description: Waits until IO is readable or writable without blocking.
15
14
  email:
@@ -20,9 +19,12 @@ extensions:
20
19
  - ext/io/wait/extconf.rb
21
20
  extra_rdoc_files: []
22
21
  files:
22
+ - ".document"
23
+ - ".rdoc_options"
23
24
  - COPYING
24
25
  - Gemfile
25
26
  - README.md
27
+ - _doc/io.rb
26
28
  - ext/io/wait/depend
27
29
  - ext/io/wait/extconf.rb
28
30
  - ext/io/wait/wait.c
@@ -33,7 +35,6 @@ licenses:
33
35
  metadata:
34
36
  homepage_uri: https://github.com/ruby/io-wait
35
37
  source_code_uri: https://github.com/ruby/io-wait
36
- post_install_message:
37
38
  rdoc_options: []
38
39
  require_paths:
39
40
  - lib
@@ -41,15 +42,14 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
42
  requirements:
42
43
  - - ">="
43
44
  - !ruby/object:Gem::Version
44
- version: '0'
45
+ version: '3.0'
45
46
  required_rubygems_version: !ruby/object:Gem::Requirement
46
47
  requirements:
47
48
  - - ">="
48
49
  - !ruby/object:Gem::Version
49
50
  version: '0'
50
51
  requirements: []
51
- rubygems_version: 3.4.0.dev
52
- signing_key:
52
+ rubygems_version: 3.6.7
53
53
  specification_version: 4
54
54
  summary: Waits until IO is readable or writable without blocking.
55
55
  test_files: []