From bb2dc7e98693ad0c27c21d02f8ffd049fa2589a4 Mon Sep 17 00:00:00 2001 From: naruse Date: Wed, 27 Oct 2010 00:26:29 +0000 Subject: * cont.c: apply documentation patch by Run Paint Run Run. [ruby-core:32915] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@29604 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- ChangeLog | 5 +++++ cont.c | 49 ++++++++++++++++++++++++++++--------------------- 2 files changed, 33 insertions(+), 21 deletions(-) diff --git a/ChangeLog b/ChangeLog index 93abe653ae..dd9ebd6efc 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,3 +1,8 @@ +Wed Oct 27 09:25:46 2010 NARUSE, Yui + + * cont.c: apply documentation patch by Run Paint Run Run. + [ruby-core:32915] + Wed Oct 27 02:12:10 2010 Yusuke Endoh * object.c (Init_Object), constant.h, variable.c diff --git a/cont.c b/cont.c index 48ae896405..b0b3f41c7d 100644 --- a/cont.c +++ b/cont.c @@ -752,18 +752,19 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) /* * Document-class: Continuation * - * Continuation objects are generated by - * Kernel#callcc. They hold a return address and execution - * context, allowing a nonlocal return to the end of the - * callcc block from anywhere within a program. - * Continuations are somewhat analogous to a structured version of C's - * setjmp/longjmp (although they contain more state, so - * you might consider them closer to threads). + * Continuation objects are generated by Kernel#callcc, + * after having required continuation. They hold + * a return address and execution context, allowing a nonlocal return + * to the end of the callcc block from anywhere within a + * program. Continuations are somewhat analogous to a structured + * version of C's setjmp/longjmp (although they contain + * more state, so you might consider them closer to threads). * * For instance: * + * require "continuation" * arr = [ "Freddie", "Herbie", "Ron", "Max", "Ringo" ] - * callcc{|$cc|} + * callcc{|cc| $cc = cc} * puts(message = arr.shift) * $cc.call unless message =~ /Max/ * @@ -777,6 +778,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) * This (somewhat contrived) example allows the inner loop to abandon * processing early: * + * require "continuation" * callcc {|cont| * for i in 0..4 * print "\n#{i}: " @@ -786,7 +788,7 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) * end * end * } - * print "\n" + * puts * * produces: * @@ -800,14 +802,16 @@ cont_restore_0(rb_context_t *cont, VALUE *addr_in_prev_frame) * call-seq: * callcc {|cont| block } -> obj * - * Generates a Continuation object, which it passes to the - * associated block. Performing a cont.call will - * cause the callcc to return (as will falling through the - * end of the block). The value returned by the callcc is - * the value of the block, or the value passed to - * cont.call. See class Continuation - * for more details. Also see Kernel::throw for - * an alternative mechanism for unwinding a call stack. + * Generates a Continuation object, which it passes to + * the associated block. You need to require + * 'continuation' before using this method. Performing a + * cont.call will cause the callcc + * to return (as will falling through the end of the block). The + * value returned by the callcc is the value of the + * block, or the value passed to cont.call. See + * class Continuation for more details. Also see + * Kernel::throw for an alternative mechanism for + * unwinding a call stack. */ static VALUE @@ -1305,9 +1309,10 @@ rb_fiber_yield(int argc, VALUE *argv) * call-seq: * fiber.alive? -> true or false * - * Returns true if the fiber can still be resumed (or transferred to). - * After finishing execution of the fiber block this method will always - * return false. + * Returns true if the fiber can still be resumed (or transferred + * to). After finishing execution of the fiber block this method will + * always return false. You need to require 'fiber' + * before using this method. */ VALUE rb_fiber_alive_p(VALUE fibval) @@ -1344,7 +1349,9 @@ rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib) * * Transfer control to another fiber, resuming it from where it last * stopped or starting it if it was not resumed before. The calling - * fiber will be suspended much like in a call to Fiber.yield. + * fiber will be suspended much like in a call to + * Fiber.yield. You need to require 'fiber' + * before using this method. * * The fiber which receives the transfer call is treats it much like * a resume call. Arguments passed to transfer are treated like those -- cgit v1.2.3