Sha256: f85242cfc78834a7f6423efb22d555cb8187742365b4d236b9c6eb2b0f4a41ac
Contents?: true
Size: 411 Bytes
Versions: 10
Compression:
Stored size: 411 Bytes
Contents
module Kraps class TimeoutQueue include MonitorMixin def initialize super @cond = new_cond @queue = [] end def enq(item) synchronize do @queue << item @cond.signal end end def deq(timeout:) synchronize do @cond.wait(timeout) if @queue.empty? return @queue.empty? ? nil : @queue.shift end end end end
Version data entries
10 entries across 10 versions & 1 rubygems