lib/agent/channel.rb in agent-0.11.0 vs lib/agent/channel.rb in agent-0.12.0

- old
+ new

@@ -24,11 +24,10 @@ @skip_marshal = opts[:skip_marshal] @close_mutex = Mutex.new @queue = Queues.register(@name, @type, @max) end - # Serialization methods def marshal_load(ary) @closed, @name, @max, @type, @direction = *ary @queue = Queues[@name] @@ -43,45 +42,39 @@ # Sending methods def send(object, options={}) check_direction(:send) - q = queue - raise Errors::ChannelClosed unless q + raise Errors::ChannelClosed if @closed + q = @queue q.push(object, {:skip_marshal => @skip_marshal}.merge(options)) end alias :push :send alias :<< :send def push?; queue.push?; end alias :send? :push? - # Receiving methods def receive(options={}) check_direction(:receive) q = queue - return q.pop(options) if q - pop = Pop.new(options) - pop.close - [pop.object, false] + return q.pop(options) end alias :pop :receive def pop?; queue.pop?; end alias :receive? :pop? - # Closing methods def close @close_mutex.synchronize do raise Errors::ChannelClosed if @closed @closed = true @queue.close - @queue = nil Queues.delete(@name) end end def closed?; @closed; end def open?; !@closed; end @@ -98,10 +91,9 @@ end def as_receive_only as_direction_only(:receive) end - private def as_direction_only(direction) @close_mutex.synchronize do