Sha256: 982b7092e61d9e37fc544d7d1aeaa1665cea1b335671328ad1b60506ef3ac7a4

Contents?: true

Size: 580 Bytes

Versions: 4

Compression:

Stored size: 580 Bytes

Contents

# frozen_string_literal: true
module Steam
  module Networking
    # Holds a list of Packet objects in a non-blocking thread safe queue
    class PacketList
      def initialize
        @packets = Thread::Queue.new
      end

      # Adds a Packet to the internal queue
      #
      # @param packet [Packet] the Packet to add
      def add(packet)
        @packets.push(packet)
      end

      # Removes the next message
      #
      # @return [Packet] The Packet object
      def pop
        @packets.pop(true)
      rescue ThreadError
        nil
      end
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
steamrb-0.1.3 lib/steam/networking/packet_list.rb
steamrb-0.1.2 lib/steam/networking/packet_list.rb
steamrb-0.1.1 lib/steam/networking/packet_list.rb
steamrb-0.1.0 lib/steam/networking/packet_list.rb