Class: Solargraph::LanguageServer::Host::Cataloger
- Inherits:
-
Object
- Object
- Solargraph::LanguageServer::Host::Cataloger
- Defined in:
- lib/solargraph/language_server/host/cataloger.rb
Instance Method Summary collapse
-
#initialize(host) ⇒ Cataloger
constructor
A new instance of Cataloger.
-
#ping ⇒ void
Notify the Cataloger that changes are pending.
-
#start ⇒ void
Start the catalog thread.
-
#stop ⇒ void
Stop the catalog thread.
-
#stopped? ⇒ Boolean
True if the cataloger is stopped.
- #synchronizing? ⇒ Boolean
Constructor Details
#initialize(host) ⇒ Cataloger
Returns a new instance of Cataloger.
5 6 7 8 9 10 |
# File 'lib/solargraph/language_server/host/cataloger.rb', line 5 def initialize host @host = host @mutex = Mutex.new @stopped = true @pings = [] end |
Instance Method Details
#ping ⇒ void
This method returns an undefined value.
Notify the Cataloger that changes are pending.
15 16 17 |
# File 'lib/solargraph/language_server/host/cataloger.rb', line 15 def ping mutex.synchronize { pings.push nil } end |
#start ⇒ void
This method returns an undefined value.
Start the catalog thread.
40 41 42 43 44 45 46 47 48 49 50 51 52 53 |
# File 'lib/solargraph/language_server/host/cataloger.rb', line 40 def start return unless stopped? @stopped = false Thread.new do until stopped? sleep 0.1 next if pings.empty? mutex.synchronize do host.catalog pings.clear end end end end |
#stop ⇒ void
This method returns an undefined value.
Stop the catalog thread.
26 27 28 |
# File 'lib/solargraph/language_server/host/cataloger.rb', line 26 def stop @stopped = true end |
#stopped? ⇒ Boolean
True if the cataloger is stopped.
33 34 35 |
# File 'lib/solargraph/language_server/host/cataloger.rb', line 33 def stopped? @stopped end |
#synchronizing? ⇒ Boolean
19 20 21 |
# File 'lib/solargraph/language_server/host/cataloger.rb', line 19 def synchronizing? !pings.empty? end |