diff options
author | Koichi Sasada <[email protected]> | 2022-05-20 15:47:20 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2022-05-20 17:37:46 +0900 |
commit | eab99b1d4b61fb85d994534826922f96cd14ae58 (patch) | |
tree | 16f57c273520f5ae7987d8879d13dcf39e64d5c2 /vm.c | |
parent | aeea88174d88264469b406003765c7efdcd53edf (diff) |
`rb_thread_t::serial` for debug
`rb_thread_t::serial` is auto-incremented serial number for
threads and it can overflow, it means the serial is not a ID
for each thread, it is only for debug print.
`RUBY_DEBUG_LOG` shows this information.
Also skip EC related information if EC is NULL. This patch
enable to use `RUBY_DEBUG_LOG` without setup EC.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5921
Diffstat (limited to 'vm.c')
-rw-r--r-- | vm.c | 5 |
1 files changed, 5 insertions, 0 deletions
@@ -3292,6 +3292,11 @@ th_init(rb_thread_t *th, VALUE self, rb_vm_t *vm, rb_ractor_t *r) th->name = Qnil; th->report_on_exception = vm->thread_report_on_exception; th->ext_config.ractor_safe = true; + +#if USE_RUBY_DEBUG_LOG + static rb_atomic_t thread_serial = 0; + th->serial = RUBY_ATOMIC_FETCH_ADD(thread_serial, 1); +#endif } VALUE |