Class: Solargraph::LanguageServer::Host::MessageWorker
- Inherits:
-
Object
- Object
- Solargraph::LanguageServer::Host::MessageWorker
- Defined in:
- lib/solargraph/language_server/host/message_worker.rb
Overview
A serial worker Thread to handle incoming messages.
Constant Summary collapse
- UPDATE_METHODS =
[ 'textDocument/didChange', 'textDocument/didClose', 'textDocument/didOpen', 'textDocument/didSave', 'workspace/didChangeConfiguration', 'workspace/didChangeWatchedFiles', 'workspace/didCreateFiles', 'workspace/didChangeWorkspaceFolders', 'workspace/didDeleteFiles', 'workspace/didRenameFiles' ].freeze
Instance Method Summary collapse
-
#initialize(host) ⇒ MessageWorker
constructor
A new instance of MessageWorker.
-
#messages ⇒ Array<Hash>
pending handle messages.
- #queue(message) ⇒ void
- #start ⇒ void
- #stop ⇒ void
- #stopped? ⇒ Boolean
- #tick ⇒ void
Constructor Details
#initialize(host) ⇒ MessageWorker
Returns a new instance of MessageWorker.
23 24 25 26 27 28 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 23 def initialize(host) @host = host @mutex = Mutex.new @resource = ConditionVariable.new @stopped = true end |
Instance Method Details
#messages ⇒ Array<Hash>
pending handle messages
32 33 34 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 32 def @messages ||= [] end |
#queue(message) ⇒ void
This method returns an undefined value.
47 48 49 50 51 52 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 47 def queue() @mutex.synchronize do .push() @resource.signal end end |
#start ⇒ void
This method returns an undefined value.
55 56 57 58 59 60 61 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 55 def start return unless @stopped @stopped = false Thread.new do tick until stopped? end end |
#stop ⇒ void
This method returns an undefined value.
41 42 43 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 41 def stop @stopped = true end |
#stopped? ⇒ Boolean
36 37 38 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 36 def stopped? @stopped end |
#tick ⇒ void
This method returns an undefined value.
64 65 66 67 68 69 70 71 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 64 def tick = @mutex.synchronize do @resource.wait(@mutex) if .empty? end handler = @host.receive() handler&.send_response end |