Class: Threach::Queue
- Inherits:
-
ArrayBlockingQueue
- Object
- ArrayBlockingQueue
- Threach::Queue
- Defined in:
- lib/jruby_threach.rb
Overview
An ArrayBlockingQueue with reasonable defaults for timeouts.
Constant Summary collapse
- MS =
TimeUnit::MILLISECONDS
Instance Method Summary collapse
-
#initialize(size = 5, timeout_in_ms = 5) ⇒ Queue
constructor
Create a new queue.
-
#pop ⇒ Object?
Pop an object ouf of the queue.
-
#push(obj) ⇒ Boolean
Try to add an object to the queue.
Constructor Details
#initialize(size = 5, timeout_in_ms = 5) ⇒ Queue
Create a new queue
30 31 32 33 |
# File 'lib/jruby_threach.rb', line 30 def initialize (size=5, timeout_in_ms = 5) super(size) @timeout = timeout_in_ms end |
Instance Method Details
#pop ⇒ Object?
Pop an object ouf of the queue
44 45 46 |
# File 'lib/jruby_threach.rb', line 44 def pop self.poll @timeout, MS end |
#push(obj) ⇒ Boolean
Try to add an object to the queue
38 39 40 |
# File 'lib/jruby_threach.rb', line 38 def push obj self.offer obj, @timeout, MS end |