Class: CLI::UI::Spinner::Async
- Inherits:
-
Object
- Object
- CLI::UI::Spinner::Async
- Extended by:
- T::Sig
- Defined in:
- lib/cli/ui/spinner/async.rb
Class Method Summary collapse
Instance Method Summary collapse
-
#initialize(title) ⇒ Async
constructor
A new instance of Async.
- #stop ⇒ Object
Methods included from T::Sig
Constructor Details
#initialize(title) ⇒ Async
Returns a new instance of Async.
33 34 35 36 37 38 39 40 |
# File 'lib/cli/ui/spinner/async.rb', line 33 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
16 17 18 |
# File 'lib/cli/ui/spinner/async.rb', line 16 def start(title) new(title) end |
Instance Method Details
#stop ⇒ Object
45 46 47 48 |
# File 'lib/cli/ui/spinner/async.rb', line 45 def stop @m.synchronize { @cv.signal } @t.value end |