Sha256: 9c1f9b8b27b36dd6a3345da1f6da54fc1bebd38b229c5940c5cfed0414cf19bf
Contents?: true
Size: 444 Bytes
Versions: 3
Compression:
Stored size: 444 Bytes
Contents
require 'thread' class MessageDb def initialize @sempahore = Mutex.new @message_db = [] end def create(message) @sempahore.synchronize do message[:id] = @message_db.size @message_db << message @message_db.size end end def find_all @sempahore.synchronize do @message_db.dup end end def find(id) @sempahore.synchronize do @message_db[id] end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
malm-0.0.4 | lib/message_db.rb |
malm-0.0.3 | lib/message_db.rb |
malm-0.0.2 | lib/message_db.rb |