Class: Capybara::Lightpanda::Utils::Event
- Inherits:
-
Concurrent::Event
- Object
- Concurrent::Event
- Capybara::Lightpanda::Utils::Event
- Defined in:
- lib/capybara/lightpanda/utils/event.rb
Overview
Concurrent::Event with an iteration counter so callers can detect that the event was reset (e.g. a new navigation started) while they were waiting on it. Mirrors ferrum’s Utils::Event.
The base Concurrent::Event allows wait/set/reset cycles, but a wait that returns true after a reset → set is indistinguishable from one that returned true on the original set. The iteration counter, bumped on every reset, lets callers compare before and after to tell whether the event was raced by a reset.
Instance Method Summary collapse
-
#initialize ⇒ Event
constructor
A new instance of Event.
- #iteration ⇒ Object
- #reset ⇒ Object
Constructor Details
#initialize ⇒ Event
Returns a new instance of Event.
18 19 20 21 |
# File 'lib/capybara/lightpanda/utils/event.rb', line 18 def initialize super @iteration = 0 end |
Instance Method Details
#iteration ⇒ Object
23 24 25 |
# File 'lib/capybara/lightpanda/utils/event.rb', line 23 def iteration synchronize { @iteration } end |
#reset ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/capybara/lightpanda/utils/event.rb', line 27 def reset synchronize do @iteration += 1 @set = false if @set @iteration end end |