summaryrefslogtreecommitdiff
path: root/cont.c
diff options
context:
space:
mode:
authorayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-02 10:13:28 +0000
committerayumin <ayumin@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2012-05-02 10:13:28 +0000
commit6f72a6dcb5c5945bdf1727914a786451f9668b9e (patch)
tree7090ac2d696e57d449bf84bc9fd6fe1bdf806f9a /cont.c
parent8de9bb275f575ba1b5a2e6d44372c2f536e6bde1 (diff)
* cont.c: Improved Fiber documentation.[ruby-core:44540][Bug #6343]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@35519 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'cont.c')
-rw-r--r--cont.c26
1 files changed, 26 insertions, 0 deletions
diff --git a/cont.c b/cont.c
index 97602ad..d900d5a 100644
--- a/cont.c
+++ b/cont.c
@@ -1425,6 +1425,32 @@ rb_fiber_m_resume(int argc, VALUE *argv, VALUE fib)
* You cannot resume a fiber that transferred control to another one.
* This will cause a double resume error. You need to transfer control
* back to this fiber before it can yield and resume.
+ *
+ * Example:
+ *
+ * fiber1 = Fiber.new do
+ * puts "In Fiber 1"
+ * Fiber.yield
+ * end
+ *
+ * fiber2 = Fiber.new do
+ * puts "In Fiber 2"
+ * fiber1.transfer
+ * end
+ *
+ * fiber3 = Fiber.new do
+ * puts "In Fiber 3"
+ * end
+ *
+ * fiber2.resume
+ * fiber3.resume
+ *
+ * <em>produces</em>
+ *
+ * I am in fiber2
+ * I am in fiber1
+ * I am in fiber3
+ *
*/
static VALUE
rb_fiber_m_transfer(int argc, VALUE *argv, VALUE fibval)