[前][次][番号順一覧][スレッド一覧]

ruby-changes:70401

From: zverok <ko1@a...>
Date: Tue, 21 Dec 2021 08:33:07 +0900 (JST)
Subject: [ruby-changes:70401] eae5a34be3 (master): Add SchedulerInterface#timeout_after and #address_resolve docs

https://git.ruby-lang.org/ruby.git/commit/?id=eae5a34be3

From eae5a34be3113120ec17ca87604befaad5ee3fab Mon Sep 17 00:00:00 2001
From: zverok <zverok.offline@g...>
Date: Sat, 18 Dec 2021 01:01:46 +0200
Subject: Add SchedulerInterface#timeout_after and #address_resolve docs

---
 cont.c | 39 +++++++++++++++++++++++++++++++++++++++
 1 file changed, 39 insertions(+)

diff --git a/cont.c b/cont.c
index f2d7788c562..abbfac52160 100644
--- a/cont.c
+++ b/cont.c
@@ -2922,6 +2922,8 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self) https://github.com/ruby/ruby/blob/trunk/cont.c#L2922
  *  * #io_wait, #io_read, and #io_write
  *  * #process_wait
  *  * #kernel_sleep
+ *  * #timeout_after
+ *  * #address_resolve
  *  * #block and #unblock
  *  * (the list is expanded as Ruby developers make more methods having non-blocking calls)
  *
@@ -3082,6 +3084,41 @@ rb_fiber_scheduler_interface_kernel_sleep(VALUE self) https://github.com/ruby/ruby/blob/trunk/cont.c#L3084
 {
 }
 
+/*
+ *  Document-method: SchedulerInterface#address_resolve
+ *  call-seq: address_resolve(hostname) -> array_of_stings or nil
+ *
+ *  Invoked by Socket::getaddrinfo and is expected to provide hostname resolution
+ *  in a non-blocking way.
+ *
+ *  The method is expected to return an array of strings corresponding to ip
+ *  addresses the +hostname+ is resolved to, or +nil+ if it can not be resolved.
+ *
+ *  The method support should be considered _experimental_.
+ */
+static VALUE
+rb_fiber_scheduler_interface_address_resolve(VALUE self)
+{
+}
+
+/*
+ *  Document-method: SchedulerInterface#address_resolve
+ *  call-seq: timeout_after(duration, exception_class, *exception_args, &block) -> obj
+ *
+ *  Invoked by Timeout.timeout to perform execution time control in a non-blocking way.
+ *
+ *  The method is expected to execute a +block+, and if its execution takes longer
+ *  than +duration+, to raise +exception_class+ constructed with +exception_args+.
+ *
+ *  If the block is executed successfully, its result should be returned.
+ *
+ *  The method support should be considered _experimental_.
+ */
+static VALUE
+rb_fiber_scheduler_interface_timeout_after(VALUE self)
+{
+}
+
 /*
  *  Document-method: SchedulerInterface#block
  *  call-seq: block(blocker, timeout = nil)
@@ -3198,6 +3235,8 @@ Init_Cont(void) https://github.com/ruby/ruby/blob/trunk/cont.c#L3235
     rb_define_method(rb_cFiberScheduler, "io_read", rb_fiber_scheduler_interface_io_read, 0);
     rb_define_method(rb_cFiberScheduler, "io_write", rb_fiber_scheduler_interface_io_write, 0);
     rb_define_method(rb_cFiberScheduler, "kernel_sleep", rb_fiber_scheduler_interface_kernel_sleep, 0);
+    rb_define_method(rb_cFiberScheduler, "address_resolve", rb_fiber_scheduler_interface_address_resolve, 0);
+    rb_define_method(rb_cFiberScheduler, "timeout_after", rb_fiber_scheduler_interface_timeout_after, 0);
     rb_define_method(rb_cFiberScheduler, "block", rb_fiber_scheduler_interface_block, 0);
     rb_define_method(rb_cFiberScheduler, "unblock", rb_fiber_scheduler_interface_unblock, 0);
     rb_define_method(rb_cFiberScheduler, "fiber", rb_fiber_scheduler_interface_fiber, 0);
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]