mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Ractor.allocate should not be allowed
Ractor.allocate and Ractor#dup should not be allowed like Thread. [Bug #17642]
This commit is contained in:
		
							parent
							
								
									9a5da2dcff
								
							
						
					
					
						commit
						7b9476fbfa
					
				
				
				Notes:
				
					git
				
				2021-02-18 22:35:57 +09:00 
				
			
			
			
		
		
					 2 changed files with 20 additions and 0 deletions
				
			
		|  | @ -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 | ||||
|  |  | |||
							
								
								
									
										2
									
								
								ractor.c
									
										
									
									
									
								
							
							
						
						
									
										2
									
								
								ractor.c
									
										
									
									
									
								
							|  | @ -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); | ||||
|  |  | |||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue
	
	 Koichi Sasada
						Koichi Sasada