class Riml::WarningBuffer
Thread-safe output buffer. Used internally for all Riml
warnings. Only one of these objects exists during compile.
Constants
- WARNING_FMT
- WRITE_LOCK
This class acts as a singleton, so no instance-level mutexes are required. This facilitates locking both class and instance methods with a single mutex.
Attributes
stream[R]
buffer[R]
Public Class Methods
new(*warnings)
click to toggle source
# File lib/riml/warning_buffer.rb, line 23 def initialize(*warnings) @buffer = warnings end
stream=(stream)
click to toggle source
# File lib/riml/warning_buffer.rb, line 12 def stream=(stream) WRITE_LOCK.synchronize { @stream = stream } end
Public Instance Methods
<<(warning)
click to toggle source
# File lib/riml/warning_buffer.rb, line 27 def <<(warning) WRITE_LOCK.synchronize { buffer << warning } end
Also aliased as: push
clear()
click to toggle source
# File lib/riml/warning_buffer.rb, line 41 def clear WRITE_LOCK.synchronize { buffer.clear } end
flush()
click to toggle source
# File lib/riml/warning_buffer.rb, line 32 def flush WRITE_LOCK.synchronize do stream = self.class.stream buffer.each { |w| stream.puts WARNING_FMT % w } buffer.clear stream.flush end end