Class: LogSinks::Pumps::DedicatedThreadPump

Inherits:
InThreadPump show all
Defined in:
lib/log_sinks/pumps/dedicated_thread_pump.rb

Overview

A pump that drains events to the sink in a dedicated thread

Instance Method Summary collapse

Constructor Details

#initialize(sink) ⇒ DedicatedThreadPump

Returns a new instance of DedicatedThreadPump.



12
13
14
15
16
17
18
19
# File 'lib/log_sinks/pumps/dedicated_thread_pump.rb', line 12

def initialize(sink)
  super

  @drain_buffer = Concurrent::AtomicReference.new
  @drain_buffer.set(Immutable::Deque.empty)
  @has_events_flag = Concurrent::Event.new
  @drain_thread = Thread.new { drain_thread_func }
end

Instance Method Details

#receive(event) ⇒ Object



21
22
23
24
# File 'lib/log_sinks/pumps/dedicated_thread_pump.rb', line 21

def receive(event)
  @drain_buffer.update { |buffer| buffer.push(event) }
  @has_events_flag.set
end