Class: Command
- Inherits:
-
Object
- Object
- Command
- Defined in:
- lib/Olib/core/command.rb
Constant Summary collapse
- LOCK =
Mutex.new
Class Method Summary collapse
Class Method Details
.lock ⇒ Object
4 5 6 |
# File 'lib/Olib/core/command.rb', line 4 def self.lock() LOCK.synchronize { yield } end |
.try_or_fail(seconds: 5, command: nil) ⇒ Object
8 9 10 11 12 13 |
# File 'lib/Olib/core/command.rb', line 8 def self.try_or_fail(seconds: 5, command: nil) fput(command) expiry = Time.now + seconds wait_until do yield or Time.now > expiry end Err[command: command, seconds: seconds, reason: :not_found] if Time.now > expiry end |