Bug #17573 » use_main_ractor_ec_on_threads_without_ec.patch
| ext/-test-/postponed_job/postponed_job.c | ||
|---|---|---|
| 
         return self; 
   | 
||
| 
     } 
   | 
||
| 
     #ifdef HAVE_PTHREAD_H 
   | 
||
| 
     #include <pthread.h> 
   | 
||
| 
     static void * 
   | 
||
| 
     pjob_register_in_c_thread_i(void *obj) 
   | 
||
| 
     { 
   | 
||
| 
         rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj); 
   | 
||
| 
         rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj); 
   | 
||
| 
         rb_postponed_job_register_one(0, pjob_one_callback, (void *)obj); 
   | 
||
| 
         return NULL; 
   | 
||
| 
     } 
   | 
||
| 
     static VALUE 
   | 
||
| 
     pjob_register_in_c_thread(VALUE self, VALUE obj) 
   | 
||
| 
     { 
   | 
||
| 
     	pthread_t thread; 
   | 
||
| 
     	if(pthread_create(&thread, NULL, pjob_register_in_c_thread_i, (void *)obj)) { 
   | 
||
| 
     		return Qfalse; 
   | 
||
| 
     	} 
   | 
||
| 
     	if(pthread_join(thread, NULL)) { 
   | 
||
| 
     		return Qfalse; 
   | 
||
| 
     	} 
   | 
||
| 
     	return Qtrue; 
   | 
||
| 
     } 
   | 
||
| 
     #endif 
   | 
||
| 
     void 
   | 
||
| 
     Init_postponed_job(VALUE self) 
   | 
||
| 
     { 
   | 
||
| ... | ... | |
| 
         rb_define_module_function(mBug, "postponed_job_register", pjob_register, 1); 
   | 
||
| 
         rb_define_module_function(mBug, "postponed_job_register_one", pjob_register_one, 1); 
   | 
||
| 
         rb_define_module_function(mBug, "postponed_job_call_direct", pjob_call_direct, 1); 
   | 
||
| 
     #ifdef HAVE_PTHREAD_H 
   | 
||
| 
         rb_define_module_function(mBug, "postponed_job_register_in_c_thread", pjob_register_in_c_thread, 1); 
   | 
||
| 
     #endif 
   | 
||
| 
     } 
   | 
||
| ractor.c | ||
|---|---|---|
| 
         RB_VM_UNLOCK(); 
   | 
||
| 
     } 
   | 
||
| 
     rb_execution_context_t * 
   | 
||
| 
     MJIT_FUNC_EXPORTED rb_execution_context_t * 
   | 
||
| 
     rb_vm_main_ractor_ec(rb_vm_t *vm) 
   | 
||
| 
     { 
   | 
||
| 
         return vm->ractor.main_ractor->threads.running_ec; 
   | 
||
| test/-ext-/postponed_job/test_postponed_job.rb | ||
|---|---|---|
| 
         Bug.postponed_job_register_one(ary = []) 
   | 
||
| 
         assert_equal [1], ary 
   | 
||
| 
       end 
   | 
||
| 
       if Bug.respond_to?(:postponed_job_register_in_c_thread) 
   | 
||
| 
         def test_register_in_c_thread 
   | 
||
| 
           assert Bug.postponed_job_register_in_c_thread(ary = []) 
   | 
||
| 
           assert_equal [1], ary 
   | 
||
| 
         end 
   | 
||
| 
       end 
   | 
||
| 
     end 
   | 
||
| vm_core.h | ||
|---|---|---|
| 
         } 
   | 
||
| 
     } 
   | 
||
| 
     static inline rb_vm_t * rb_current_vm(void); 
   | 
||
| 
     static inline rb_execution_context_t * 
   | 
||
| 
     rb_current_execution_context(void) 
   | 
||
| 
     { 
   | 
||
| ... | ... | |
| 
     #else 
   | 
||
| 
         rb_execution_context_t *ec = native_tls_get(ruby_current_ec_key); 
   | 
||
| 
     #endif 
   | 
||
| 
         if (ec == NULL) { 
   | 
||
| 
     	    ec = rb_vm_main_ractor_ec(GET_VM()); 
   | 
||
| 
         } 
   | 
||
| 
         VM_ASSERT(ec != NULL); 
   | 
||
| 
         return ec; 
   | 
||
| 
     } 
   | 
||
- « Previous
 - 1
 - 2
 - Next »