[前][次][番号順一覧][スレッド一覧]

ruby-changes:71873

From: Benoit <ko1@a...>
Date: Thu, 19 May 2022 07:19:58 +0900 (JST)
Subject: [ruby-changes:71873] 240ac9eaa8 (master): [ruby/timeout] Synchronize all accesses to @done

https://git.ruby-lang.org/ruby.git/commit/?id=240ac9eaa8

From 240ac9eaa8d3dab8f7dd5f29f67c7ee8d4d05d86 Mon Sep 17 00:00:00 2001
From: Benoit Daloze <eregontp@g...>
Date: Sun, 15 May 2022 13:49:31 +0200
Subject: [ruby/timeout] Synchronize all accesses to @done

* So it is trivially correct.
* Performance seems the same overall.

https://github.com/ruby/timeout/commit/5e0d8e1637
---
 lib/timeout.rb | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/lib/timeout.rb b/lib/timeout.rb
index 414983088c..4659ec3279 100644
--- a/lib/timeout.rb
+++ b/lib/timeout.rb
@@ -67,11 +67,13 @@ module Timeout https://github.com/ruby/ruby/blob/trunk/lib/timeout.rb#L67
       @message = message
 
       @mutex = Mutex.new
-      @done = false
+      @done = false # protected by @mutex
     end
 
     def done?
-      @done
+      @mutex.synchronize do
+        @done
+      end
     end
 
     def expired?(now)
-- 
cgit v1.2.1


--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]