summaryrefslogtreecommitdiff
path: root/thread.c
diff options
context:
space:
mode:
authorzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-25 03:50:20 +0000
committerzzak <zzak@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2013-02-25 03:50:20 +0000
commit84e8862c56d90000d0ad8eb166e8fb81b5bba943 (patch)
treefcd55b4f6ddc97cf1ce89293f6a989f3bfd5e9c3 /thread.c
parent1580dd29dddc02c210f96e6250d2f20df3241ab1 (diff)
* thread.c: Document Thread::new, clean up ::fork and mention calling
super if subclassing Thread git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@39484 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'thread.c')
-rw-r--r--thread.c30
1 files changed, 26 insertions, 4 deletions
diff --git a/thread.c b/thread.c
index d74356b879..baacb526a7 100644
--- a/thread.c
+++ b/thread.c
@@ -622,7 +622,26 @@ thread_create_core(VALUE thval, VALUE args, VALUE (*fn)(ANYARGS))
return thval;
}
-/* :nodoc: */
+/*
+ * call-seq:
+ * Thread.new { ... } -> thread
+ * Thread.new(*args, &proc) -> thread
+ * Thread.new(*args) { |args| ... } -> thread
+ *
+ * Creates a new thread executing the given block.
+ *
+ * Any +args+ given to ::new will be passed to the block:
+ *
+ * arr = []
+ * a, b, c = 1, 2, 3
+ * Thread.new(a,b,c) { |d,e,f| arr << d << e << f }.join
+ * arr #=> [1, 2, 3]
+ *
+ * A ThreadError exception is raised if ::new is called without a block.
+ *
+ * If you're going to subclass Thread, be sure to call super in your
+ * +initialize+ method, otherwise a ThreadError will be raised.
+ */
static VALUE
thread_s_new(int argc, VALUE *argv, VALUE klass)
{
@@ -646,9 +665,12 @@ thread_s_new(int argc, VALUE *argv, VALUE klass)
* Thread.start([args]*) {|args| block } -> thread
* Thread.fork([args]*) {|args| block } -> thread
*
- * Basically the same as <code>Thread::new</code>. However, if class
- * <code>Thread</code> is subclassed, then calling <code>start</code> in that
- * subclass will not invoke the subclass's <code>initialize</code> method.
+ * Basically the same as ::new. However, if class Thread is subclassed, then
+ * calling +start+ in that subclass will not invoke the subclass's
+ * +initialize+ method.
+ *
+ * If you're going to subclass Thread, be sure to call super in your
+ * +initialize+ method, otherwise a ThreadError will be raised.
*/
static VALUE