Sha256: 64065b63cae99d8480db5a151cbd132eefb3610ae38b6d623c55755a79e6603f

Contents?: true

Size: 705 Bytes

Versions: 4

Compression:

Stored size: 705 Bytes

Contents

module DeadlySerious
  module Engine
    class SocketSinkRecvr < SocketChannel

      attr_reader :io_name

      def initialize(name, _config)
        super
        @io_name = format('tcp://*:%d', port)
        @minion = master.spawn_minion { |ctx| ctx.bind(:PULL, @io_name) }
      end

      def each
        return enum_for(:each) unless block_given?
        clients = 0
        loop do
          msg = @minion.recv
          if msg == END_MSG
            clients -= 1
            break if clients <= 0
          elsif msg == RDY_MSG
            clients += 1
          else
            yield msg
          end
        end
      end

      def close
        @minion.explode
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
deadly_serious-2.0.0.pre.rc4 lib/deadly_serious/engine/channel/socket/socket_sink_recvr.rb
deadly_serious-2.0.0.pre.rc3 lib/deadly_serious/engine/channel/socket/socket_sink_recvr.rb
deadly_serious-2.0.0.pre.rc2 lib/deadly_serious/engine/channel/socket/socket_sink_recvr.rb
deadly_serious-2.0.0.pre.rc1 lib/deadly_serious/engine/channel/socket/socket_sink_recvr.rb