io-wait 0.3.6 → 1.0.0

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: 2cece766b90e4d81cd9f633898dbe10bfb4c50ad82be6f2caee138df7047ed3c
4
- data.tar.gz: 0a7bb7fad1bb08afe84a64debfcec609e4f341173ded73745e5fd72e5bae8d17
3
+ metadata.gz: e840aeccf62ace0f185f0c01a338dc56d2d3a9dd460f1d6c8c9a1b8922a496e7
4
+ data.tar.gz: 479cc43d9ea99894a26fdf077b9aba104dd94eb415203ff37118d40661a9bbda
5
5
  SHA512:
6
- metadata.gz: 498ed5a2e45eb6e5201fb59d5f4bc47e4b4ed7948a0813a0f9849a858fcc4faec0574958f638afdcb881ea8e691bd8f7715f722c5d9fd0ab7d6ede15f4484d76
7
- data.tar.gz: b7ea14ccee049182560f902f722f6c263c5d8015685e5969a3c25bbea630064f6bb2d5549706272d2143e6590bd1cd814d8763fdb70f6c3b9a34d4b82d17666c
6
+ metadata.gz: cf81ae33a384f6c6de2d14743d5d85bf3796a782f08310cc558ba435e4ecbc9f044fb0db330e2f00112729017f7d6439b71bd482fdc3bf7841d2c94e97dd92a0
7
+ data.tar.gz: 202d42a5ce573fc50252c0bcdcb7a5c1c820d091c12ca520212e735528ddfd226a53818852de686bced1ffbed7dd6cab72ac920a2e58af4f80709b94e24f0e11
data/.document CHANGED
@@ -1,6 +1,2 @@
1
1
  COPYING
2
- ChangeLog
3
2
  README.md
4
- _doc/
5
- ext/
6
- logs/ChangeLog-*
data/README.md CHANGED
@@ -2,28 +2,4 @@
2
2
 
3
3
  This gem provides the feature for waiting until IO is readable or writable without blocking.
4
4
 
5
- ## Installation
6
-
7
- Add this line to your application's Gemfile:
8
-
9
- ```ruby
10
- gem 'io-wait'
11
- ```
12
-
13
- And then execute:
14
-
15
- $ bundle install
16
-
17
- Or install it yourself as:
18
-
19
- $ gem install io-wait
20
-
21
- ## Development
22
-
23
- After checking out the repo, run `bin/setup` to install dependencies. Then, run `rake test` to run the tests. You can also run `bin/console` for an interactive prompt that will allow you to experiment.
24
-
25
- To install this gem onto your local machine, run `bundle exec rake install`. To release a new version, update the version number in `version.rb`, and then run `bundle exec rake release`, which will create a git tag for the version, push git commits and tags, and push the `.gem` file to [rubygems.org](https://rubygems.org).
26
-
27
- ## Contributing
28
-
29
- Bug reports and pull requests are welcome on GitHub at https://github.com/ruby/io-wait.
5
+ **Note:** This gem is empty and deprecated. All functionality was moved into core Ruby as of version 3.2.
data/lib/io/wait.rb ADDED
@@ -0,0 +1 @@
1
+ warn "The io-wait gem is deprecated; all functionality ships with Ruby 3.2 and higher."
metadata CHANGED
@@ -1,32 +1,28 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: io-wait
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.6
4
+ version: 1.0.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Nobu Nakada
8
8
  - Charles Oliver Nutter
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2025-11-12 00:00:00.000000000 Z
11
+ date: 2026-09-15 00:00:00.000000000 Z
12
12
  dependencies: []
13
- description: Waits until IO is readable or writable without blocking.
13
+ description: 'Deprecated: All functionality ships with Ruby 3.2 and higher.'
14
14
  email:
15
15
  - nobu@ruby-lang.org
16
16
  - headius@headius.com
17
17
  executables: []
18
- extensions:
19
- - ext/io/wait/extconf.rb
18
+ extensions: []
20
19
  extra_rdoc_files: []
21
20
  files:
22
21
  - ".document"
23
22
  - ".rdoc_options"
24
23
  - COPYING
25
24
  - README.md
26
- - _doc/io.rb
27
- - ext/io/wait/depend
28
- - ext/io/wait/extconf.rb
29
- - ext/io/wait/wait.c
25
+ - lib/io/wait.rb
30
26
  homepage: https://github.com/ruby/io-wait
31
27
  licenses:
32
28
  - Ruby
@@ -41,7 +37,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
41
37
  requirements:
42
38
  - - ">="
43
39
  - !ruby/object:Gem::Version
44
- version: '3.0'
40
+ version: '3.2'
45
41
  required_rubygems_version: !ruby/object:Gem::Requirement
46
42
  requirements:
47
43
  - - ">="
@@ -50,5 +46,5 @@ required_rubygems_version: !ruby/object:Gem::Requirement
50
46
  requirements: []
51
47
  rubygems_version: 3.6.7
52
48
  specification_version: 4
53
- summary: Waits until IO is readable or writable without blocking.
49
+ summary: 'Deprecated: All functionality ships with Ruby 3.2 and higher.'
54
50
  test_files: []
data/_doc/io.rb DELETED
@@ -1,3 +0,0 @@
1
- # See {IO}[https://docs.ruby-lang.org/en/master/IO.html]
2
- class IO
3
- end
data/ext/io/wait/depend DELETED
@@ -1,18 +0,0 @@
1
- # AUTOGENERATED DEPENDENCIES START
2
- wait.o: $(RUBY_EXTCONF_H)
3
- wait.o: $(arch_hdrdir)/ruby/config.h
4
- wait.o: $(hdrdir)/ruby.h
5
- wait.o: $(hdrdir)/ruby/assert.h
6
- wait.o: $(hdrdir)/ruby/backward.h
7
- wait.o: $(hdrdir)/ruby/defines.h
8
- wait.o: $(hdrdir)/ruby/encoding.h
9
- wait.o: $(hdrdir)/ruby/intern.h
10
- wait.o: $(hdrdir)/ruby/io.h
11
- wait.o: $(hdrdir)/ruby/missing.h
12
- wait.o: $(hdrdir)/ruby/onigmo.h
13
- wait.o: $(hdrdir)/ruby/oniguruma.h
14
- wait.o: $(hdrdir)/ruby/ruby.h
15
- wait.o: $(hdrdir)/ruby/st.h
16
- wait.o: $(hdrdir)/ruby/subst.h
17
- wait.o: wait.c
18
- # AUTOGENERATED DEPENDENCIES END
@@ -1,21 +0,0 @@
1
- # frozen_string_literal: false
2
- require 'mkmf'
3
-
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
16
- else
17
- if have_func("rb_w32_ioctlsocket", "ruby.h")
18
- have_func("rb_w32_is_socket", "ruby.h")
19
- create_makefile(target)
20
- end
21
- end
data/ext/io/wait/wait.c DELETED
@@ -1,439 +0,0 @@
1
- /* -*- c-file-style: "ruby"; indent-tabs-mode: t -*- */
2
- /**********************************************************************
3
-
4
- io/wait.c -
5
-
6
- $Author$
7
- created at: Tue Aug 28 09:08:06 JST 2001
8
-
9
- All the files in this distribution are covered under the Ruby's
10
- license (see the file COPYING).
11
-
12
- **********************************************************************/
13
-
14
- #include "ruby.h"
15
- #include "ruby/io.h"
16
-
17
- #include <sys/types.h>
18
- #if defined(HAVE_UNISTD_H) && (defined(__sun))
19
- #include <unistd.h>
20
- #endif
21
- #if defined(HAVE_SYS_IOCTL_H)
22
- #include <sys/ioctl.h>
23
- #endif
24
- #if defined(FIONREAD_HEADER)
25
- #include FIONREAD_HEADER
26
- #endif
27
-
28
- #ifdef HAVE_RB_W32_IOCTLSOCKET
29
- #define ioctl ioctlsocket
30
- #define ioctl_arg u_long
31
- #define ioctl_arg2num(i) ULONG2NUM(i)
32
- #else
33
- #define ioctl_arg int
34
- #define ioctl_arg2num(i) INT2NUM(i)
35
- #endif
36
-
37
- #ifdef HAVE_RB_W32_IS_SOCKET
38
- #define FIONREAD_POSSIBLE_P(fd) rb_w32_is_socket(fd)
39
- #else
40
- #define FIONREAD_POSSIBLE_P(fd) ((void)(fd),Qtrue)
41
- #endif
42
-
43
- #ifndef HAVE_RB_IO_WAIT
44
- static struct timeval *
45
- get_timeout(int argc, VALUE *argv, struct timeval *timerec)
46
- {
47
- VALUE timeout = Qnil;
48
- rb_check_arity(argc, 0, 1);
49
- if (!argc || NIL_P(timeout = argv[0])) {
50
- return NULL;
51
- }
52
- else {
53
- *timerec = rb_time_interval(timeout);
54
- return timerec;
55
- }
56
- }
57
-
58
- static int
59
- wait_for_single_fd(rb_io_t *fptr, int events, struct timeval *tv)
60
- {
61
- int i = rb_wait_for_single_fd(fptr->fd, events, tv);
62
- if (i < 0)
63
- rb_sys_fail(0);
64
- rb_io_check_closed(fptr);
65
- return (i & events);
66
- }
67
- #endif
68
-
69
- /*
70
- * call-seq:
71
- * io.nread -> int
72
- *
73
- * Returns number of bytes that can be read without blocking.
74
- * Returns zero if no information available.
75
- *
76
- * You must require 'io/wait' to use this method.
77
- */
78
-
79
- static VALUE
80
- io_nread(VALUE io)
81
- {
82
- rb_io_t *fptr;
83
- int len;
84
- ioctl_arg n;
85
-
86
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "IO#nread is deprecated; use wait_readable instead");
87
- GetOpenFile(io, fptr);
88
- rb_io_check_char_readable(fptr);
89
- len = rb_io_read_pending(fptr);
90
- if (len > 0) return INT2FIX(len);
91
-
92
- #ifdef HAVE_RB_IO_DESCRIPTOR
93
- int fd = rb_io_descriptor(io);
94
- #else
95
- int fd = fptr->fd;
96
- #endif
97
-
98
- if (!FIONREAD_POSSIBLE_P(fd)) return INT2FIX(0);
99
- if (ioctl(fd, FIONREAD, &n)) return INT2FIX(0);
100
- if (n > 0) return ioctl_arg2num(n);
101
- return INT2FIX(0);
102
- }
103
-
104
- #ifdef HAVE_RB_IO_WAIT
105
- static VALUE
106
- io_wait_event(VALUE io, int event, VALUE timeout, int return_io)
107
- {
108
- VALUE result = rb_io_wait(io, RB_INT2NUM(event), timeout);
109
-
110
- if (!RB_TEST(result)) {
111
- return Qnil;
112
- }
113
-
114
- int mask = RB_NUM2INT(result);
115
-
116
- if (mask & event) {
117
- if (return_io)
118
- return io;
119
- else
120
- return result;
121
- }
122
- else {
123
- return Qfalse;
124
- }
125
- }
126
- #endif
127
-
128
- /*
129
- * call-seq:
130
- * io.ready? -> truthy or falsy
131
- *
132
- * Returns a truthy value if input available without blocking, or a
133
- * falsy value.
134
- *
135
- * You must require 'io/wait' to use this method.
136
- */
137
-
138
- static VALUE
139
- io_ready_p(VALUE io)
140
- {
141
- rb_io_t *fptr;
142
- #ifndef HAVE_RB_IO_WAIT
143
- struct timeval tv = {0, 0};
144
- #endif
145
-
146
- rb_category_warn(RB_WARN_CATEGORY_DEPRECATED, "IO#ready? is deprecated; use wait_readable instead");
147
- GetOpenFile(io, fptr);
148
- rb_io_check_char_readable(fptr);
149
- if (rb_io_read_pending(fptr)) return Qtrue;
150
-
151
- #ifndef HAVE_RB_IO_WAIT
152
- return wait_for_single_fd(fptr, RB_WAITFD_IN, &tv) ? Qtrue : Qfalse;
153
- #else
154
- return io_wait_event(io, RUBY_IO_READABLE, RB_INT2NUM(0), 1);
155
- #endif
156
- }
157
-
158
- /* Ruby 3.2+ can define these methods. This macro indicates that case. */
159
- #ifndef RUBY_IO_WAIT_METHODS
160
-
161
- /*
162
- * call-seq:
163
- * io.wait_readable -> truthy or falsy
164
- * io.wait_readable(timeout) -> truthy or falsy
165
- *
166
- * Waits until IO is readable and returns a truthy value, or a falsy
167
- * value when times out. Returns a truthy value immediately when
168
- * buffered data is available.
169
- *
170
- * You must require 'io/wait' to use this method.
171
- */
172
-
173
- static VALUE
174
- io_wait_readable(int argc, VALUE *argv, VALUE io)
175
- {
176
- rb_io_t *fptr;
177
- #ifndef HAVE_RB_IO_WAIT
178
- struct timeval timerec;
179
- struct timeval *tv;
180
- #endif
181
-
182
- GetOpenFile(io, fptr);
183
- rb_io_check_char_readable(fptr);
184
-
185
- #ifndef HAVE_RB_IO_WAIT
186
- tv = get_timeout(argc, argv, &timerec);
187
- #endif
188
- if (rb_io_read_pending(fptr)) return Qtrue;
189
-
190
- #ifndef HAVE_RB_IO_WAIT
191
- if (wait_for_single_fd(fptr, RB_WAITFD_IN, tv)) {
192
- return io;
193
- }
194
- return Qnil;
195
- #else
196
- rb_check_arity(argc, 0, 1);
197
- VALUE timeout = (argc == 1 ? argv[0] : Qnil);
198
-
199
- return io_wait_event(io, RUBY_IO_READABLE, timeout, 1);
200
- #endif
201
- }
202
-
203
- /*
204
- * call-seq:
205
- * io.wait_writable -> truthy or falsy
206
- * io.wait_writable(timeout) -> truthy or falsy
207
- *
208
- * Waits until IO is writable and returns a truthy value or a falsy
209
- * value when times out.
210
- *
211
- * You must require 'io/wait' to use this method.
212
- */
213
- static VALUE
214
- io_wait_writable(int argc, VALUE *argv, VALUE io)
215
- {
216
- rb_io_t *fptr;
217
- #ifndef HAVE_RB_IO_WAIT
218
- struct timeval timerec;
219
- struct timeval *tv;
220
- #endif
221
-
222
- GetOpenFile(io, fptr);
223
- rb_io_check_writable(fptr);
224
-
225
- #ifndef HAVE_RB_IO_WAIT
226
- tv = get_timeout(argc, argv, &timerec);
227
- if (wait_for_single_fd(fptr, RB_WAITFD_OUT, tv)) {
228
- return io;
229
- }
230
- return Qnil;
231
- #else
232
- rb_check_arity(argc, 0, 1);
233
- VALUE timeout = (argc == 1 ? argv[0] : Qnil);
234
-
235
- return io_wait_event(io, RUBY_IO_WRITABLE, timeout, 1);
236
- #endif
237
- }
238
-
239
- #ifdef HAVE_RB_IO_WAIT
240
- /*
241
- * call-seq:
242
- * io.wait_priority -> truthy or falsy
243
- * io.wait_priority(timeout) -> truthy or falsy
244
- *
245
- * Waits until IO is priority and returns a truthy value or a falsy
246
- * value when times out. Priority data is sent and received using
247
- * the Socket::MSG_OOB flag and is typically limited to streams.
248
- *
249
- * You must require 'io/wait' to use this method.
250
- */
251
- static VALUE
252
- io_wait_priority(int argc, VALUE *argv, VALUE io)
253
- {
254
- rb_io_t *fptr = NULL;
255
-
256
- RB_IO_POINTER(io, fptr);
257
- rb_io_check_char_readable(fptr);
258
-
259
- if (rb_io_read_pending(fptr)) return Qtrue;
260
-
261
- rb_check_arity(argc, 0, 1);
262
- VALUE timeout = argc == 1 ? argv[0] : Qnil;
263
-
264
- return io_wait_event(io, RUBY_IO_PRIORITY, timeout, 1);
265
- }
266
- #endif
267
-
268
- static int
269
- wait_mode_sym(VALUE mode)
270
- {
271
- if (mode == ID2SYM(rb_intern("r"))) {
272
- return RB_WAITFD_IN;
273
- }
274
- if (mode == ID2SYM(rb_intern("read"))) {
275
- return RB_WAITFD_IN;
276
- }
277
- if (mode == ID2SYM(rb_intern("readable"))) {
278
- return RB_WAITFD_IN;
279
- }
280
- if (mode == ID2SYM(rb_intern("w"))) {
281
- return RB_WAITFD_OUT;
282
- }
283
- if (mode == ID2SYM(rb_intern("write"))) {
284
- return RB_WAITFD_OUT;
285
- }
286
- if (mode == ID2SYM(rb_intern("writable"))) {
287
- return RB_WAITFD_OUT;
288
- }
289
- if (mode == ID2SYM(rb_intern("rw"))) {
290
- return RB_WAITFD_IN|RB_WAITFD_OUT;
291
- }
292
- if (mode == ID2SYM(rb_intern("read_write"))) {
293
- return RB_WAITFD_IN|RB_WAITFD_OUT;
294
- }
295
- if (mode == ID2SYM(rb_intern("readable_writable"))) {
296
- return RB_WAITFD_IN|RB_WAITFD_OUT;
297
- }
298
- rb_raise(rb_eArgError, "unsupported mode: %"PRIsVALUE, mode);
299
- return 0;
300
- }
301
-
302
- #ifdef HAVE_RB_IO_WAIT
303
- static inline rb_io_event_t
304
- io_event_from_value(VALUE value)
305
- {
306
- int events = RB_NUM2INT(value);
307
-
308
- if (events <= 0) rb_raise(rb_eArgError, "Events must be positive integer!");
309
-
310
- return events;
311
- }
312
- #endif
313
-
314
- /*
315
- * call-seq:
316
- * io.wait(events, timeout) -> event mask, false or nil
317
- * io.wait(*event_symbols[, timeout]) -> self, true, or false
318
- *
319
- * Waits until the IO becomes ready for the specified events and returns the
320
- * subset of events that become ready, or a falsy value when times out.
321
- *
322
- * The events can be a bit mask of +IO::READABLE+, +IO::WRITABLE+ or
323
- * +IO::PRIORITY+.
324
- *
325
- * Returns an event mask (truthy value) immediately when buffered data is
326
- * available.
327
- *
328
- * The second form: if one or more event symbols (+:read+, +:write+, or
329
- * +:read_write+) are passed, the event mask is the bit OR of the bitmask
330
- * corresponding to those symbols. In this form, +timeout+ is optional, the
331
- * order of the arguments is arbitrary, and returns +io+ if any of the
332
- * events is ready.
333
- *
334
- * You must require 'io/wait' to use this method.
335
- */
336
-
337
- static VALUE
338
- io_wait(int argc, VALUE *argv, VALUE io)
339
- {
340
- #ifndef HAVE_RB_IO_WAIT
341
- rb_io_t *fptr;
342
- struct timeval timerec;
343
- struct timeval *tv = NULL;
344
- int event = 0;
345
- int i;
346
-
347
- GetOpenFile(io, fptr);
348
- for (i = 0; i < argc; ++i) {
349
- if (SYMBOL_P(argv[i])) {
350
- event |= wait_mode_sym(argv[i]);
351
- }
352
- else {
353
- *(tv = &timerec) = rb_time_interval(argv[i]);
354
- }
355
- }
356
- /* rb_time_interval() and might_mode() might convert the argument */
357
- rb_io_check_closed(fptr);
358
- if (!event) event = RB_WAITFD_IN;
359
- if ((event & RB_WAITFD_IN) && rb_io_read_pending(fptr))
360
- return Qtrue;
361
- if (wait_for_single_fd(fptr, event, tv))
362
- return io;
363
- return Qnil;
364
- #else
365
- VALUE timeout = Qundef;
366
- rb_io_event_t events = 0;
367
- int i, return_io = 0;
368
-
369
- if (argc != 2 || (RB_SYMBOL_P(argv[0]) || RB_SYMBOL_P(argv[1]))) {
370
- /* We'd prefer to return the actual mask, but this form would return the io itself: */
371
- return_io = 1;
372
-
373
- /* Slow/messy path: */
374
- for (i = 0; i < argc; i += 1) {
375
- if (RB_SYMBOL_P(argv[i])) {
376
- events |= wait_mode_sym(argv[i]);
377
- }
378
- else if (timeout == Qundef) {
379
- rb_time_interval(timeout = argv[i]);
380
- }
381
- else {
382
- rb_raise(rb_eArgError, "timeout given more than once");
383
- }
384
- }
385
-
386
- if (timeout == Qundef) timeout = Qnil;
387
-
388
- if (events == 0) {
389
- events = RUBY_IO_READABLE;
390
- }
391
- }
392
- else /* argc == 2 and neither are symbols */ {
393
- /* This is the fast path: */
394
- events = io_event_from_value(argv[0]);
395
- timeout = argv[1];
396
- }
397
-
398
- if (events & RUBY_IO_READABLE) {
399
- rb_io_t *fptr = NULL;
400
- RB_IO_POINTER(io, fptr);
401
-
402
- if (rb_io_read_pending(fptr)) {
403
- /* This was the original behaviour: */
404
- if (return_io) return Qtrue;
405
- /* New behaviour always returns an event mask: */
406
- else return RB_INT2NUM(RUBY_IO_READABLE);
407
- }
408
- }
409
-
410
- return io_wait_event(io, events, timeout, return_io);
411
- #endif
412
- }
413
-
414
- #endif /* RUBY_IO_WAIT_METHODS */
415
-
416
- /*
417
- * IO wait methods
418
- */
419
-
420
- void
421
- Init_wait(void)
422
- {
423
- #ifdef HAVE_RB_EXT_RACTOR_SAFE
424
- RB_EXT_RACTOR_SAFE(true);
425
- #endif
426
-
427
- rb_define_method(rb_cIO, "nread", io_nread, 0);
428
- rb_define_method(rb_cIO, "ready?", io_ready_p, 0);
429
-
430
- #ifndef RUBY_IO_WAIT_METHODS
431
- rb_define_method(rb_cIO, "wait", io_wait, -1);
432
-
433
- rb_define_method(rb_cIO, "wait_readable", io_wait_readable, -1);
434
- rb_define_method(rb_cIO, "wait_writable", io_wait_writable, -1);
435
- #ifdef HAVE_RB_IO_WAIT
436
- rb_define_method(rb_cIO, "wait_priority", io_wait_priority, -1);
437
- #endif
438
- #endif
439
- }