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.



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

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

Instance Method Details

#closeObject



23
24
25
# File 'lib/rigor/language_server/synchronized_writer.rb', line 23

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

#write(message) ⇒ Object



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

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