File: //usr/share/ri/3.0.0/system/Fiber/schedule-c.ri
U:RDoc::AnyMethod[iI"
schedule:ETI"Fiber::schedule;TT:publico:RDoc::Markup::Document:@parts[o:RDoc::Markup::Paragraph; [I"XThe method is <em>expected</em> to immediately run the provided block of code in a ;TI"!separate non-blocking fiber.;To:RDoc::Markup::BlankLine o:RDoc::Markup::Verbatim; [I"puts "Go to sleep!"
;TI"
;TI"*Fiber.set_scheduler(MyScheduler.new)
;TI"
;TI"Fiber.schedule do
;TI" puts "Going to sleep"
;TI" sleep(1)
;TI" puts "I slept well"
;TI" end
;TI"
;TI"$puts "Wakey-wakey, sleepyhead"
;T:@format0o;
; [I"MAssuming MyScheduler is properly implemented, this program will produce:;T@o;; [
I"Go to sleep!
;TI"Going to sleep
;TI"Wakey-wakey, sleepyhead
;TI"...1 sec pause here...
;TI"I slept well
;T;
0o;
; [ I"S...e.g. on the first blocking operation inside the Fiber (<tt>sleep(1)</tt>), ;TI"Qthe control is yielded at the outside code (main fiber), and <em>at the end ;TI"Rof the execution</em>, the scheduler takes care of properly resuming all the ;TI"blocked fibers.;T@o;
; [ I"SNote that the behavior described above is how the method is <em>expected</em> ;TI"Sto behave, actual behavior is up to the current scheduler's implementation of ;TI"QFiber::SchedulerInterface#fiber method. Ruby doesn't enforce this method to ;TI""behave in any particular way.;T@o;
; [I"4If the scheduler is not set, the method raises ;TI"8<tt>RuntimeError (No scheduler is available!)</tt>.;T:
@fileI"cont.c;T:0@omit_headings_from_table_of_contents_below0I"-Fiber.schedule { |*args| ... } -> fiber
;T0[ I"(*args);T@7FI"
Fiber;TcRDoc::NormalClass00