Class: CLI::UI::Spinner::Async

Inherits:
Object
  • Object
show all
Extended by:
T::Sig
Defined in:
lib/cli/ui/spinner/async.rb

Class Method Summary collapse

Instance Method Summary collapse

Methods included from T::Sig

sig

Constructor Details

#initialize(title) ⇒ Async

Returns a new instance of Async.


27
28
29
30
31
32
33
34
# File 'lib/cli/ui/spinner/async.rb', line 27

def initialize(title)
  require 'thread'
  sg = CLI::UI::Spinner::SpinGroup.new
  @m = Mutex.new
  @cv = ConditionVariable.new
  sg.add(title) { @m.synchronize { @cv.wait(@m) } }
  @t = Thread.new { sg.wait }
end

Class Method Details

.start(title) ⇒ Object


11
12
13
# File 'lib/cli/ui/spinner/async.rb', line 11

def self.start(title)
  new(title)
end

Instance Method Details

#stopObject


39
40
41
42
# File 'lib/cli/ui/spinner/async.rb', line 39

def stop
  @m.synchronize { @cv.signal }
  @t.value
end