Class: Solargraph::LanguageServer::Host::Cataloger

Inherits:
Object
  • Object
show all
Defined in:
lib/solargraph/language_server/host/cataloger.rb

Instance Method Summary collapse

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

#pingvoid

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

#startvoid

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

#stopvoid

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.

Returns:

  • (Boolean)


33
34
35
# File 'lib/solargraph/language_server/host/cataloger.rb', line 33

def stopped?
  @stopped
end

#synchronizing?Boolean

Returns:

  • (Boolean)


19
20
21
# File 'lib/solargraph/language_server/host/cataloger.rb', line 19

def synchronizing?
  !pings.empty?
end