lib/0mq/poll_interruptible.rb
# Same as Poll#run, but will yield [nil, nil] to the block if interrupted.
# Return value may be an empty hash if the poller was killed.
Same as Poll#run, but will yield [nil, nil] to the block if interrupted.
Return value may be an empty hash if the poller was killed.
Same as Poll#run but will yield [ nil nil ] to the block if interrupted . Return value may be an empty hash if the poller was killed .
def run(&block)
      raise "#{self} cannot run; it was permanently killed." if @dead
      super do |socket, revents|
        if socket == @int_sock_rep || socket == @int_sock_pull
          key, * = socket.recv_array
          kill = key == "KILL"
          blocking = socket == @int_sock_rep
          unless kill
            result = @interruptions.pop.call
            @outerruptions.push result if blocking
          end
          block.call nil, nil if block
          socket.send_array ["OKAY"] if blocking
          if kill
            @int_sock_rep.close
            @int_sock_pull.close
            @dead = true
          end
        else
          block.call socket, revents if block
        end
      end.tap do |hash|
        hash.delete @int_sock_rep
        hash.delete @int_sock_pull
      end
    end
def run ( & block ) raise "#{self} cannot run; it was permanently killed." if @dead super do | socket , revents | if socket == @int_sock_rep || socket == @int_sock_pull key , * = socket . recv_array kill = key == "KILL" blocking = socket == @int_sock_rep unless kill result = @interruptions . pop . call @outerruptions . push result if blocking end block . call nil , nil if block socket . send_array [ "OKAY" ] if blocking if kill @int_sock_rep . close @int_sock_pull . close @dead = true end else block . call socket , revents if block end end . tap do | hash | hash . delete @int_sock_rep hash . delete @int_sock_pull end end
Same as Poll#run, but will yield [nil, nil] to the block if interrupted.
Same as Poll#run but will yield [ nil nil ] to the block if interrupted .
# Call the user block of #interrupt and store the return value # Call the user block of #run # Send a response if the interruption was blocking
block
<not_specific>