mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
Add status to Ractor#inspect
This commit is contained in:
parent
84c4c7bec8
commit
d5fa66156a
Notes:
git
2020-09-20 23:11:14 +09:00
2 changed files with 27 additions and 3 deletions
|
@ -17,6 +17,27 @@ assert_equal "must be called with a block", %q{
|
|||
end
|
||||
}
|
||||
|
||||
# Ractor#inspect
|
||||
assert_equal "#<Ractor:#1 running>", %q{
|
||||
Ractor.current.inspect
|
||||
}
|
||||
|
||||
assert_match /^#<Ractor:#([^ ]*?) bootstraptest.tmp.rb:[0-9]+ blocking>$/, %q{
|
||||
r = Ractor.new { Ractor.recv }
|
||||
r.inspect
|
||||
}
|
||||
|
||||
assert_match /^#<Ractor:#([^ ]*?) bootstraptest.tmp.rb:[0-9]+ terminated>$/, %q{
|
||||
r = Ractor.new { '' }
|
||||
r.take
|
||||
r.inspect
|
||||
}
|
||||
|
||||
assert_match /^#<Ractor:#([^ ]*?) Test Ractor bootstraptest.tmp.rb:[0-9]+ blocking>$/, %q{
|
||||
r = Ractor.new(name: 'Test Ractor') { Ractor.recv }
|
||||
r.inspect
|
||||
}
|
||||
|
||||
# A return value of a Ractor block will be a message from the Ractor.
|
||||
assert_equal 'ok', %q{
|
||||
# join
|
||||
|
|
|
@ -132,7 +132,10 @@ class Ractor
|
|||
loc = __builtin_cexpr! %q{ RACTOR_PTR(self)->loc }
|
||||
name = __builtin_cexpr! %q{ RACTOR_PTR(self)->name }
|
||||
id = __builtin_cexpr! %q{ INT2FIX(RACTOR_PTR(self)->id) }
|
||||
"#<Ractor:##{id}#{name ? ' '+name : ''}#{loc ? " " + loc : ''}>"
|
||||
status = __builtin_cexpr! %q{
|
||||
rb_str_new2(ractor_status_str(RACTOR_PTR(self)->status_))
|
||||
}
|
||||
"#<Ractor:##{id}#{name ? ' '+name : ''}#{loc ? " " + loc : ''} #{status}>"
|
||||
end
|
||||
|
||||
def name
|
||||
|
|
Loading…
Reference in a new issue