Module: Datadog::Core::Workers::Queue
Overview
Adds queue behavior to workers, with a buffer to which items can be queued then dequeued.
Defined Under Namespace
Modules: PrependedMethods
Instance Attribute Summary collapse
Class Method Summary
collapse
Instance Method Summary
collapse
Instance Attribute Details
#buffer ⇒ Object
20
21
22
|
# File 'lib/datadog/core/workers/queue.rb', line 20
def buffer
@buffer ||= []
end
|
Class Method Details
.included(base) ⇒ Object
9
10
11
|
# File 'lib/datadog/core/workers/queue.rb', line 9
def self.included(base)
base.prepend(PrependedMethods)
end
|
Instance Method Details
#dequeue ⇒ Object
28
29
30
|
# File 'lib/datadog/core/workers/queue.rb', line 28
def dequeue
buffer.shift
end
|
#enqueue(*args) ⇒ Object
24
25
26
|
# File 'lib/datadog/core/workers/queue.rb', line 24
def enqueue(*args)
buffer.push(args)
end
|
#work_pending? ⇒ Boolean
Are there more items to be processed next?
33
34
35
|
# File 'lib/datadog/core/workers/queue.rb', line 33
def work_pending?
!buffer.empty?
end
|