Skip to content

Commit

Permalink
Add SchedulerInterface#timeout_after and #address_resolve docs
Browse files Browse the repository at this point in the history
  • Loading branch information
zverok authored and ioquatix committed Dec 20, 2021
1 parent 224dfb2 commit eae5a34
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions cont.c
Expand Up @@ -2922,6 +2922,8 @@ rb_fiber_pool_initialize(int argc, VALUE* argv, VALUE self)
* * #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)
*
Expand Down Expand Up @@ -3082,6 +3084,41 @@ rb_fiber_scheduler_interface_kernel_sleep(VALUE self)
{
}

/*
* 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)
Expand Down Expand Up @@ -3198,6 +3235,8 @@ Init_Cont(void)
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);
Expand Down

0 comments on commit eae5a34

Please sign in to comment.