diff options
author | John Hawthorn <[email protected]> | 2025-05-13 22:36:09 -0700 |
---|---|---|
committer | John Hawthorn <[email protected]> | 2025-05-15 15:18:10 -0700 |
commit | d67d169aeae8b05f8b06f4829de6d5f14059cfea () | |
tree | c0be842a91d79045a639b715130cbedecddf264b /thread_win32.c | |
parent | d845da05e83a2c2929ef8d4fd829804d44f292d3 (diff) |
Use atomics for system_working global
Although it almost certainly works in this case, volatile is best not used for multi-threaded code. Using atomics instead avoids warnings from TSan. This also simplifies some logic, as system_working was previously only ever assigned to 1, so --system_working <= 0 should always return true (unless it underflowed).
Notes: Merged: https://.com/ruby/ruby/pull/13333
-rw-r--r-- | thread_win32.c | 16 |
1 files changed, 8 insertions, 8 deletions
@@ -798,14 +798,14 @@ rb_thread_create_timer_thread(void) static int native_stop_timer_thread(void) { - int stopped = --system_working <= 0; - if (stopped) { - SetEvent(timer_thread.lock); - native_thread_join(timer_thread.id); - CloseHandle(timer_thread.lock); - timer_thread.lock = 0; - } - return stopped; } static void |