Class: Rigor::LanguageServer::SynchronizedWriter

Inherits:
Object
  • Object
show all
Defined in:
lib/rigor/language_server/synchronized_writer.rb

Overview

Wraps the LSP gem's Io::Writer with a Mutex so concurrent writes (the dispatch loop's response writes + the Debouncer's async publishDiagnostics writes) don't interleave on the shared STDOUT.

Pass-through proxy: #write(message) is the only call site the rest of the LSP uses; #close is forwarded for completeness.

Instance Method Summary collapse

Constructor Details

#initialize(inner) ⇒ SynchronizedWriter

Returns a new instance of SynchronizedWriter.



11
12
13
14
# File 'lib/rigor/language_server/synchronized_writer.rb', line 11

def initialize(inner)
  @inner = inner
  @mutex = Mutex.new
end

Instance Method Details

#closeObject



20
21
22
# File 'lib/rigor/language_server/synchronized_writer.rb', line 20

def close
  @mutex.synchronize { @inner.close }
end

#write(message) ⇒ Object



16
17
18
# File 'lib/rigor/language_server/synchronized_writer.rb', line 16

def write(message)
  @mutex.synchronize { @inner.write(message) }
end