Sha256: 2e643c8a81b6465c0317f86cb500fee2a5a9b71c93b7433dee5e23c7f41ecb08
Contents?: true
Size: 530 Bytes
Versions: 5
Compression:
Stored size: 530 Bytes
Contents
module Dcha # :nodoc: class PacketManager < Hash attr_reader :todo def initialize @todo = Queue.new end def <<(chunk) self[chunk.tag] ||= [] self[chunk.tag] << chunk self[chunk.tag].uniq! check(chunk) end private def check(chunk) return unless self[chunk.tag].size == chunk.total event = Oj.load(self[chunk.tag].sort.map(&:to_s).join) @todo << event # TODO: Release memory if buffer not completed delete(chunk.tag) end end end
Version data entries
5 entries across 5 versions & 1 rubygems