| Server IP : 162.214.74.102 / Your IP : 216.73.217.21 Web Server : Apache System : Linux dedi-4363141.lrsys.com.br 3.10.0-1160.119.1.el7.tuxcare.els25.x86_64 #1 SMP Wed Oct 1 17:37:27 UTC 2025 x86_64 User : lrsys ( 1015) PHP Version : 5.6.40 Disable Function : exec,passthru,shell_exec,system MySQL : ON | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /proc/self/root/opt/cpanel/ea-ruby24/root/usr/share/ri/system/Continuation/ |
Upload File : |
U:RDoc::NormalClass[iI"Continuation:ET@I"Object;To:RDoc::Markup::Document:@parts[o;;[o:RDoc::Markup::Paragraph;[I":Continuation objects are generated by Kernel#callcc, ;TI"<after having +require+d <i>continuation</i>. They hold ;TI"Ha return address and execution context, allowing a nonlocal return ;TI"Hto the end of the <code>callcc</code> block from anywhere within a ;TI"Cprogram. Continuations are somewhat analogous to a structured ;TI"Gversion of C's <code>setjmp/longjmp</code> (although they contain ;TI"?more state, so you might consider them closer to threads).;To:RDoc::Markup::BlankLine o; ;[I"For instance:;T@o:RDoc::Markup::Verbatim;[
I"require "continuation"
;TI":arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
;TI"callcc{|cc| $cc = cc}
;TI"puts(message = arr.shift)
;TI"&$cc.call unless message =~ /Max/
;T:@format0o; ;[I"<em>produces:</em>;T@o;;[ I"
Freddie
;TI"Herbie
;TI" Ron
;TI" Max
;T;0o; ;[I"/Also you can call callcc in other methods:;T@o;;[I"require "continuation"
;TI"
;TI"def g
;TI"< arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ]
;TI" cc = callcc { |cc| cc }
;TI" puts arr.shift
;TI" return cc, arr.size
;TI" end
;TI"
;TI"def f
;TI" c, size = g
;TI" c.call(c) if size > 1
;TI" end
;TI"
;TI"f
;T;0o; ;[I"HThis (somewhat contrived) example allows the inner loop to abandon ;TI"processing early:;T@o;;[I"require "continuation"
;TI"callcc {|cont|
;TI" for i in 0..4
;TI" print "\n#{i}: "
;TI" for j in i*5...(i+1)*5
;TI"" cont.call() if j == 17
;TI" printf "%3d", j
;TI"
end
;TI" end
;TI"}
;TI"
puts
;T;0o; ;[I"<em>produces:</em>;T@o;;[ I"0: 0 1 2 3 4
;TI"1: 5 6 7 8 9
;TI"2: 10 11 12 13 14
;TI"3: 15 16;T;0:
@fileI"cont.c;T:0@omit_headings_from_table_of_contents_below0;
0;0[ [ [ [[I"
class;T[[:public[ [:protected[ [:private[ [I"
instance;T[[;[[I"[];TI"cont.c;T[I" call;T@m[;[ [;[ [ [U:RDoc::Context::Section[i 0o;;[ ;
0;0[@X@XcRDoc::TopLevel