Class: Applitools::Future
- Inherits:
-
Object
- Object
- Applitools::Future
- Defined in:
- lib/applitools/core/future.rb
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#result ⇒ Object
Returns the value of attribute result.
-
#semaphore ⇒ Object
Returns the value of attribute semaphore.
-
#thread ⇒ Object
Returns the value of attribute thread.
Instance Method Summary collapse
- #get ⇒ Object
-
#initialize(semaphore, &block) ⇒ Future
constructor
A new instance of Future.
Constructor Details
#initialize(semaphore, &block) ⇒ Future
Returns a new instance of Future.
5 6 7 8 9 10 11 12 13 14 15 16 17 18 |
# File 'lib/applitools/core/future.rb', line 5 def initialize(semaphore, &block) raise Applitools::EyesIllegalArgument, 'Applitools::Future must be initialized with a block' unless block_given? self.block = block self.semaphore = semaphore self.thread = Thread.new do begin self.result = block.call(semaphore) rescue StandardError => e Applitools::EyesLogger.logger.error "Failed to execute future" Applitools::EyesLogger.logger.error e. Applitools::EyesLogger.logger.error e.backtrace.join( ' ') end end end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
3 4 5 |
# File 'lib/applitools/core/future.rb', line 3 def block @block end |
#result ⇒ Object
Returns the value of attribute result.
3 4 5 |
# File 'lib/applitools/core/future.rb', line 3 def result @result end |
#semaphore ⇒ Object
Returns the value of attribute semaphore.
3 4 5 |
# File 'lib/applitools/core/future.rb', line 3 def semaphore @semaphore end |
#thread ⇒ Object
Returns the value of attribute thread.
3 4 5 |
# File 'lib/applitools/core/future.rb', line 3 def thread @thread end |
Instance Method Details
#get ⇒ Object
20 21 22 23 |
# File 'lib/applitools/core/future.rb', line 20 def get thread.join(15) result end |