diff options
author | Samuel Williams <[email protected]> | 2021-12-21 12:30:17 +1300 |
---|---|---|
committer | Samuel Williams <[email protected]> | 2021-12-21 12:32:54 +1300 |
commit | 711342d93565092a8348ac5538bc4b4288d384ba (patch) | |
tree | dc381a4d94a9ea1ca5f1cd26a31108a81932ee5d | |
parent | eae5a34be3113120ec17ca87604befaad5ee3fab (diff) |
Update cont.c
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5280
-rw-r--r-- | cont.c | 31 |
1 files changed, 23 insertions, 8 deletions
@@ -3103,16 +3103,31 @@ 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+. + * call-seq: timeout_after(duration, exception_class, *exception_arguments, &block) -> result of block + * + * Limit the execution time of a given +block+ to the given +duration+ if + * possible. When a non-blocking operation causes the +block+'s execution time + * to exceed the specified +duration+, that non-blocking operation should be + * interrupted by raising the specified +exception_class+ constructed with the + * given +exception_arguments+. + * + * General execution timeouts are often considered risky. This implementation + * will only interrupt non-blocking operations. This is by design because it's + * expected that non-blocking operations can fail for a variety of + * unpredictable reasons, so applications should already be robust in handling + * these conditions. + * + * However, as a result of this design, if the +block+ does not invoke any + * non-blocking operations, it will be impossible to interrupt it. If you + * desire to provide predictable points for timeouts, consider adding + * +sleep(0)+. + * + * This hook is invoked by Timeout.timeout and can also be invoked directly by + * the scheduler. * - * If the block is executed successfully, its result should be returned. + * If the block is executed successfully, its result will be returned. * - * The method support should be considered _experimental_. + * The exception will typically be raised using Fiber#raise. */ static VALUE rb_fiber_scheduler_interface_timeout_after(VALUE self) |