Class: Kernai::Recorder::Sink::MemorySink

Inherits:
Base
  • Object
show all
Defined in:
lib/kernai/recorder.rb

Overview

Bundled sink that keeps every entry in a thread-safe Array.

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeMemorySink

Returns a new instance of MemorySink.



44
45
46
47
48
# File 'lib/kernai/recorder.rb', line 44

def initialize
  super
  @entries = []
  @mutex = Mutex.new
end

Instance Attribute Details

#entriesObject (readonly)

Returns the value of attribute entries.



42
43
44
# File 'lib/kernai/recorder.rb', line 42

def entries
  @entries
end

Instance Method Details

#clear!Object



54
55
56
# File 'lib/kernai/recorder.rb', line 54

def clear!
  @mutex.synchronize { @entries.clear }
end

#record(entry) ⇒ Object



50
51
52
# File 'lib/kernai/recorder.rb', line 50

def record(entry)
  @mutex.synchronize { @entries << entry }
end