ruby-changes:27432
From: zzak <ko1@a...>
Date: Mon, 25 Feb 2013 12:59:06 +0900 (JST)
Subject: [ruby-changes:27432] zzak:r39484 (trunk): * thread.c: Document Thread::new, clean up ::fork and mention calling
zzak 2013-02-25 12:50:20 +0900 (Mon, 25 Feb 2013) New Revision: 39484 http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=39484 Log: * thread.c: Document Thread::new, clean up ::fork and mention calling super if subclassing Thread Modified files: trunk/ChangeLog trunk/thread.c Index: ChangeLog =================================================================== --- ChangeLog (revision 39483) +++ ChangeLog (revision 39484) @@ -1,3 +1,8 @@ https://github.com/ruby/ruby/blob/trunk/ChangeLog#L1 +Mon Feb 25 12:48:00 2013 Zachary Scott <zachary@z...> + + * thread.c: Document Thread::new, clean up ::fork and mention calling + super if subclassing Thread + Mon Feb 25 12:38:50 2013 Tanaka Akira <akr@f...> * ext/socket/extconf.rb: don't test ss_family and ss_len member of Index: thread.c =================================================================== --- thread.c (revision 39483) +++ thread.c (revision 39484) @@ -622,7 +622,26 @@ thread_create_core(VALUE thval, VALUE ar https://github.com/ruby/ruby/blob/trunk/thread.c#L622 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, VALU https://github.com/ruby/ruby/blob/trunk/thread.c#L665 * 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 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/