diff options
author | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-11-17 07:30:37 +0000 |
---|---|---|
committer | matz <matz@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 1999-11-17 07:30:37 +0000 |
commit | 8e48dc16e97a783a69f0972b4882ad2faae561ea (patch) | |
tree | c25927a4f286e4ed5f3c7637076332e99287b089 /lib | |
parent | 943e99e62746388456955729e9f8417f3df5f8b5 (diff) |
19991117
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@564 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/pstore.rb | 11 | ||||
-rw-r--r-- | lib/singleton.rb | 1 |
2 files changed, 12 insertions, 0 deletions
diff --git a/lib/pstore.rb b/lib/pstore.rb index 2aa9864b58..cc90207aa3 100644 --- a/lib/pstore.rb +++ b/lib/pstore.rb @@ -78,6 +78,16 @@ class PStore begin @transaction = true value = file = nil + lock = @filename + ".lock" + loop do + begin + File::symlink("pstore::#$$", lock) + break + rescue Errno::EEXIST + rescue + sleep 1 + end + end begin File::open(@filename, "r") do |file| @table = Marshal.load(file) @@ -112,6 +122,7 @@ class PStore ensure @table = nil @transaction = false + File::unlink(lock) end value end diff --git a/lib/singleton.rb b/lib/singleton.rb index 8167a01aa8..4aea574e7a 100644 --- a/lib/singleton.rb +++ b/lib/singleton.rb @@ -14,6 +14,7 @@ module Singleton def Singleton.append_features(klass) klass.private_class_method(:new) klass.instance_eval %{ + @__instance__ = nil def instance unless @__instance__ @__instance__ = new |