Class: Applitools::Future
- Inherits:
-
Object
- Object
- Applitools::Future
- Defined in:
- lib/applitools/core/future.rb
Constant Summary collapse
- DEFAULT_TIMEOUT =
350
Class Attribute Summary collapse
-
.timeout ⇒ Object
Returns the value of attribute timeout.
Instance Attribute Summary collapse
-
#block ⇒ Object
Returns the value of attribute block.
-
#description ⇒ Object
Returns the value of attribute description.
-
#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, description = nil, &block) ⇒ Future
constructor
A new instance of Future.
Constructor Details
#initialize(semaphore, description = nil, &block) ⇒ Future
Returns a new instance of Future.
12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/applitools/core/future.rb', line 12 def initialize(semaphore, description = nil, &block) raise Applitools::EyesIllegalArgument, 'Applitools::Future must be initialized with a block' unless block_given? self.block = block self.semaphore = semaphore self.description = description self.thread = Thread.new do begin self.result = yield(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 |
Class Attribute Details
.timeout ⇒ Object
Returns the value of attribute timeout.
8 9 10 |
# File 'lib/applitools/core/future.rb', line 8 def timeout @timeout end |
Instance Attribute Details
#block ⇒ Object
Returns the value of attribute block.
5 6 7 |
# File 'lib/applitools/core/future.rb', line 5 def block @block end |
#description ⇒ Object
Returns the value of attribute description.
5 6 7 |
# File 'lib/applitools/core/future.rb', line 5 def description @description end |
#result ⇒ Object
Returns the value of attribute result.
5 6 7 |
# File 'lib/applitools/core/future.rb', line 5 def result @result end |
#semaphore ⇒ Object
Returns the value of attribute semaphore.
5 6 7 |
# File 'lib/applitools/core/future.rb', line 5 def semaphore @semaphore end |
#thread ⇒ Object
Returns the value of attribute thread.
5 6 7 |
# File 'lib/applitools/core/future.rb', line 5 def thread @thread end |
Instance Method Details
#get ⇒ Object
28 29 30 31 32 |
# File 'lib/applitools/core/future.rb', line 28 def get thread.join(self.class.timeout) raise Applitools::EyesError, "Failed to execute future - got nil result! (#{description})" if result.nil? result end |