Ractor.allocate should not be allowed

Ractor.allocate and Ractor#dup should not be allowed like Thread.
[Bug #17642]
This commit is contained in:
Koichi Sasada 2021-02-18 17:59:40 +09:00
parent 9a5da2dcff
commit 7b9476fbfa
Notes: git 2021-02-18 22:35:57 +09:00
2 changed files with 20 additions and 0 deletions

View File

@ -8,6 +8,24 @@ assert_equal 'Ractor', %q{
Ractor.new{}.class
}
# Ractor.allocate is not supported
assert_equal "[:ok, :ok]", %q{
rs = []
begin
Ractor.allocate
rescue => e
rs << :ok if e.message == 'allocator undefined for Ractor'
end
begin
Ractor.new{}.dup
rescue
rs << :ok if e.message == 'allocator undefined for Ractor'
end
rs
}
# A Ractor can have a name
assert_equal 'test-name', %q{
r = Ractor.new name: 'test-name' do

View File

@ -2088,6 +2088,8 @@ void
Init_Ractor(void)
{
rb_cRactor = rb_define_class("Ractor", rb_cObject);
rb_undef_alloc_func(rb_cRactor);
rb_eRactorError = rb_define_class_under(rb_cRactor, "Error", rb_eRuntimeError);
rb_eRactorIsolationError = rb_define_class_under(rb_cRactor, "IsolationError", rb_eRactorError);
rb_eRactorRemoteError = rb_define_class_under(rb_cRactor, "RemoteError", rb_eRactorError);