diff options
author | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-11 19:07:49 +0000 |
---|---|---|
committer | seki <seki@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2007-08-11 19:07:49 +0000 |
commit | 135bb5717402d978052ae4e674e2e38494febf7a (patch) | |
tree | 6232523c184a5c384e357f43883bbd120f2f5c35 /lib | |
parent | 3a0e807df3ecc9260bf39f687e33394306679a79 (diff) |
fix Rinda::TupleSpace keeper thread bug.
the thread is started too early. [ruby-talk:264062]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_8@12919 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'lib')
-rw-r--r-- | lib/rinda/tuplespace.rb | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/lib/rinda/tuplespace.rb b/lib/rinda/tuplespace.rb index 21389abdeb..0a9f27c5c9 100644 --- a/lib/rinda/tuplespace.rb +++ b/lib/rinda/tuplespace.rb @@ -449,7 +449,6 @@ module Rinda def write(tuple, sec=nil) entry = create_entry(tuple, sec) - start_keeper synchronize do if entry.expired? @read_waiter.find_all_template(entry).each do |template| @@ -459,6 +458,7 @@ module Rinda notify_event('delete', entry.value) else @bag.push(entry) + start_keeper if entry.expires @read_waiter.find_all_template(entry).each do |template| template.read(tuple) end @@ -484,7 +484,6 @@ module Rinda def move(port, tuple, sec=nil) template = WaitTemplateEntry.new(self, tuple, sec) yield(template) if block_given? - start_keeper synchronize do entry = @bag.find(template) if entry @@ -497,6 +496,7 @@ module Rinda begin @take_waiter.push(template) + start_keeper if template.expires while true raise RequestCanceledError if template.canceled? raise RequestExpiredError if template.expired? @@ -521,7 +521,6 @@ module Rinda def read(tuple, sec=nil) template = WaitTemplateEntry.new(self, tuple, sec) yield(template) if block_given? - start_keeper synchronize do entry = @bag.find(template) return entry.value if entry @@ -529,6 +528,7 @@ module Rinda begin @read_waiter.push(template) + start_keeper if template.expires template.wait raise RequestCanceledError if template.canceled? raise RequestExpiredError if template.expired? @@ -615,8 +615,11 @@ module Rinda def start_keeper return if @keeper && @keeper.alive? @keeper = Thread.new do - while need_keeper? - keep_clean + while true + synchronize do + break unless need_keeper? + keep_clean + end sleep(@period) end end |