Class: Threasy::Work::TimeoutQueue
- Inherits:
-
Object
- Object
- Threasy::Work::TimeoutQueue
- Includes:
- Timeout
- Defined in:
- lib/threasy/work.rb
Instance Method Summary collapse
- #clear ⇒ Object
-
#initialize ⇒ TimeoutQueue
constructor
A new instance of TimeoutQueue.
- #pop(seconds = 5) ⇒ Object
- #push(item) ⇒ Object
- #size ⇒ Object
Constructor Details
#initialize ⇒ TimeoutQueue
113 114 115 |
# File 'lib/threasy/work.rb', line 113 def initialize @queue = Queue.new end |
Instance Method Details
#clear ⇒ Object
132 133 134 |
# File 'lib/threasy/work.rb', line 132 def clear @queue.clear end |
#pop(seconds = 5) ⇒ Object
122 123 124 125 126 |
# File 'lib/threasy/work.rb', line 122 def pop(seconds = 5) timeout(seconds) { @queue.pop } rescue Timeout::Error nil end |
#push(item) ⇒ Object
117 118 119 120 |
# File 'lib/threasy/work.rb', line 117 def push(item) @queue << item true end |
#size ⇒ Object
128 129 130 |
# File 'lib/threasy/work.rb', line 128 def size @queue.size end |