[#45906] ' failures. — Tanaka Akira <akr@...>
' の扱いが変化したことで、テストが失敗しているようです。
9 messages
2012/07/04
[#45910] [ruby-trunk - Bug #6694][Open] Thread.new without block. — "ko1 (Koichi Sasada)" <redmine@...>
24 messages
2012/07/04
[#45928] Re: [ruby-cvs:43524] kosaki:r36348 (trunk): * include/ruby/ruby.h: Removed RUBY_GLOBAL_SETUP complely. It is — SASADA Koichi <ko1@...>
ささだです.
3 messages
2012/07/09
[#45973] [ruby-trunk - Bug #6751][Assigned] remove tempfiles early. — "akr (Akira Tanaka)" <akr@...>
4 messages
2012/07/18
[#45976] [ruby-trunk - Bug #6756][Open] FileUtils.rm_rf がアクセス権のない空ディレクトリを削除しない — "fumiyas (Fumiyasu SATOH)" <fumiyas@...>
9 messages
2012/07/20
[#45977] [ruby-trunk - Feature #6757][Open] [PATCH] Add Process.getsid — "fumiyas (Fumiyasu SATOH)" <fumiyas@...>
6 messages
2012/07/20
[#46012] [ruby-trunk - Feature #6812][Open] Refactor gc.c — "authorNari (Narihiro Nakamura)" <authorNari@...>
13 messages
2012/07/30
[ruby-dev:45988] [ruby-trunk - Feature #6694] Thread.new without block.
From:
"headius (Charles Nutter)" <headius@...>
Date:
2012-07-20 21:51:21 UTC
List:
ruby-dev #45988
Issue #6694 has been updated by headius (Charles Nutter).
I will comment on stack sizing on the other issue.
As far as passing params and not starting the thread, it doesn't seem like a bad API. There are other thread characteristics that could be passed at construction time like abort_on_exception, priority, and potentially things like "start" (to autostart as the current API), "daemon" to create threads that will keep the VM alive after main thread exits, and so on.
FWIW, JVM threads do not run until explicitly started. The start of the actual native thread is deferred until Thread#start is called. Thread-runtime operations raise exceptions if called before the thread is started. Simple enough.
----------------------------------------
Feature #6694: Thread.new without block.
https://bugs.ruby-lang.org/issues/6694#change-28238
Author: ko1 (Koichi Sasada)
Status: Assigned
Priority: Normal
Assignee: ko1 (Koichi Sasada)
Category: core
Target version: 2.0.0
=begin
= Abstract
Support Thread.new() without block.
Before: Thread.new(params...){|thread_local_params| ...}
After: Thread.new(proc: lambda{|tl_params...| ...}, args: params..., other_thread_config...)
= Background
Thread.new creates new Thread object and run passed block in another thread immediately. Thread.new can receive parameters and pass all parameters to block.
Thread.new(a, b, c) do |ta, tb, tc|
# ta, tb, tc is thread local
}
There are some request to specify thread configurations such as stack size described in [Ruby 1.9 - Feature #3187] (in this case, stack size for Fiber.new). However, we have no way to pass such thread configuration on the Thread.new().
= Proposal
Allow Thread.new() without block. A block will be passed with proc parameter. Passed arguments will be passed with args parameter.
# ex1
Thread.new(){...}
#=>
Thread.new(proc: -> {...})
# ex2
Thread.new(a, b, c){|ta, tb, tc| ...}
#=>
Thread.new(proc: ->(ta, tb, tc){ ... }, params: [a, b, c])
If you want to specify stack size, then:
Thread.new(stack_size: 4096, proc: proc{...}, args: [a, b, c])
Note that I'll make another ticket for thread (and fiber) creation parameters.
This change can be described with the following pseudo code:
def Thread.new(*args, &block)
if block
Thread.new_orig(*args, &block)
else
config = args[0] || raise ArgumentError
stack_size = config[:stack_size]
# ... and process another parameters
Thread.new_orig(*config[:args], &config[:proc])
end
end
= Another proposal
On the [ruby-core:43385], Nahi-san proposed that if no block given on Thread.new(), then create "waiting" thread. Thread#run kicks waiting thread with parameters.
th = Thread.new(thread_config_params)
...
th.run(params){|thread_local_params|
...
}
We can combine with proc: parameter and this proposal. If Thread.new() doesn't have block and proc: parameter, then making a waiting thread.
NOTE: Because we have already Thread#run, Thread#start is better than Thread#run?
= Note
I don't make any survey on other languages. Please give us your comments.
=end
--
http://bugs.ruby-lang.org/