diff options
author | Koichi Sasada <[email protected]> | 2022-04-22 21:19:03 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2022-04-23 03:08:27 +0900 |
commit | 03d21a4fb099da7c52e6591e17704c297871b7db (patch) | |
tree | db2d58907b7c841d8ca15967f063d229bd9e37cc /vm.c | |
parent | 69d41480ec1c91691b79f106f5376a2e2cab3a82 (diff) |
introduce struct `rb_native_thread`
`rb_thread_t` contained `native_thread_data_t` to represent
thread implementation dependent data. This patch separates
them and rename it `rb_native_thread` and point it from
`rb_thraed_t`.
Now, 1 Ruby thread (`rb_thread_t`) has 1 native thread (`rb_native_thread`).
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5836
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 13 |
1 files changed, 6 insertions, 7 deletions
@@ -3165,7 +3165,8 @@ thread_free(void *ptr) RUBY_GC_INFO("MRI main thread\n"); } else { - ruby_xfree(ptr); + ruby_xfree(th->nt); // TODO + ruby_xfree(th); } RUBY_FREE_LEAVE("thread"); @@ -3207,11 +3208,8 @@ rb_obj_is_thread(VALUE obj) static VALUE thread_alloc(VALUE klass) { - VALUE obj; rb_thread_t *th; - obj = TypedData_Make_Struct(klass, rb_thread_t, &thread_data_type, th); - - return obj; + return TypedData_Make_Struct(klass, rb_thread_t, &thread_data_type, th); } inline void @@ -3275,8 +3273,8 @@ th_init(rb_thread_t *th, VALUE self, rb_vm_t *vm, rb_ractor_t *r) th->top_self = vm->top_self; // 0 while self == 0 th->value = Qundef; -#ifdef NON_SCALAR_THREAD_ID - th->thread_id_string[0] = '\0'; +#if defined(NON_SCALAR_THREAD_ID) && !defined(__wasm__) && !defined(__EMSCRIPTEN__) + th->nt->thread_id_string[0] = '\0'; #endif th->ec->errinfo = Qnil; @@ -3947,6 +3945,7 @@ Init_BareVM(void) vm->constant_cache = rb_id_table_create(0); // setup main thread + th->nt = ZALLOC(struct rb_native_thread); Init_native_thread(th); th_init(th, 0, vm, vm->ractor.main_ractor = rb_ractor_main_alloc()); |