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 message.
this make check pending message possible, and maybe cancelled to speedup process
Constant Summary collapse
- UPDATE_METHODS =
['textDocument/didOpen', 'textDocument/didChange', 'workspace/didChangeWatchedFiles'].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.
14 15 16 17 18 19 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 14 def initialize(host) @host = host @mutex = Mutex.new @resource = ConditionVariable.new @stopped = true end |
Instance Method Details
#messages ⇒ Array<Hash>
pending handle messages
23 24 25 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 23 def @messages ||= [] end |
#queue(message) ⇒ void
This method returns an undefined value.
38 39 40 41 42 43 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 38 def queue() @mutex.synchronize do .push() @resource.signal end end |
#start ⇒ void
This method returns an undefined value.
46 47 48 49 50 51 52 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 46 def start return unless @stopped @stopped = false Thread.new do tick until stopped? end end |
#stop ⇒ void
This method returns an undefined value.
32 33 34 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 32 def stop @stopped = true end |
#stopped? ⇒ Boolean
27 28 29 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 27 def stopped? @stopped end |
#tick ⇒ void
This method returns an undefined value.
55 56 57 58 59 60 61 62 |
# File 'lib/solargraph/language_server/host/message_worker.rb', line 55 def tick = @mutex.synchronize do @resource.wait(@mutex) if .empty? end handler = @host.receive() handler&.send_response end |