Ruby on Rails | Screencasts | Download | Documentation | Weblog | Community | Source

Ticket #389: drb_store_locking.diff

File drb_store_locking.diff, 0.8 kB (added by BenStiglitz, 4 years ago)

Patch

  • drb_server.rb

    old new  
    55                                                                                 
    66require 'drb' 
    77 
    8 DRb.start_service('druby://127.0.0.1:9192', Hash.new) 
     8session_hash = Hash.new 
     9session_hash.instance_eval { @mutex = Mutex.new } 
     10 
     11class <<session_hash 
     12  def []=(key, value) 
     13    @mutex.synchronize do 
     14      super(key, value) 
     15    end 
     16  end 
     17   
     18  def [](key) 
     19    @mutex.synchronize do 
     20      super(key) 
     21    end 
     22  end 
     23   
     24  def delete(key) 
     25    @mutex.synchronize do 
     26      super(key) 
     27    end 
     28  end 
     29end 
     30 
     31DRb.start_service('druby://127.0.0.1:9192', session_hash) 
    932DRb.thread.join