mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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).
This commit is contained in:
parent
d845da05e8
commit
d67d169aea
Notes:
git
2025-05-15 22:18:22 +00:00
4 changed files with 19 additions and 24 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;
|
||||
RUBY_ATOMIC_SET(system_working, 0);
|
||||
|
||||
SetEvent(timer_thread.lock);
|
||||
native_thread_join(timer_thread.id);
|
||||
CloseHandle(timer_thread.lock);
|
||||
timer_thread.lock = 0;
|
||||
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue