Class: Steam::Networking::PacketList
- Inherits:
-
Object
- Object
- Steam::Networking::PacketList
- Defined in:
- lib/steam/networking/packet_list.rb
Overview
Holds a list of Packet objects in a non-blocking thread safe queue
Instance Method Summary collapse
-
#add(packet) ⇒ Object
Adds a Packet to the internal queue.
-
#initialize ⇒ PacketList
constructor
A new instance of PacketList.
-
#pop ⇒ Packet
Removes the next message.
Constructor Details
#initialize ⇒ PacketList
Returns a new instance of PacketList.
6 7 8 |
# File 'lib/steam/networking/packet_list.rb', line 6 def initialize @packets = Thread::Queue.new end |
Instance Method Details
#add(packet) ⇒ Object
Adds a Packet to the internal queue
13 14 15 |
# File 'lib/steam/networking/packet_list.rb', line 13 def add(packet) @packets.push(packet) end |
#pop ⇒ Packet
Removes the next message
20 21 22 23 24 |
# File 'lib/steam/networking/packet_list.rb', line 20 def pop @packets.pop(true) rescue ThreadError nil end |