Class: Kitsune::Kit::Cancellation
- Inherits:
-
Object
- Object
- Kitsune::Kit::Cancellation
- Defined in:
- lib/kitsune/kit/cancellation.rb
Defined Under Namespace
Classes: Cancelled
Instance Method Summary collapse
- #cancel! ⇒ Object
- #cancelled? ⇒ Boolean
- #check! ⇒ Object
-
#initialize ⇒ Cancellation
constructor
A new instance of Cancellation.
Constructor Details
#initialize ⇒ Cancellation
Returns a new instance of Cancellation.
8 9 10 11 |
# File 'lib/kitsune/kit/cancellation.rb', line 8 def initialize @cancelled = false @mutex = Mutex.new end |
Instance Method Details
#cancel! ⇒ Object
13 |
# File 'lib/kitsune/kit/cancellation.rb', line 13 def cancel! = @mutex.synchronize { @cancelled = true } |
#cancelled? ⇒ Boolean
14 |
# File 'lib/kitsune/kit/cancellation.rb', line 14 def cancelled? = @mutex.synchronize { @cancelled } |
#check! ⇒ Object
16 17 18 |
# File 'lib/kitsune/kit/cancellation.rb', line 16 def check! raise Cancelled, "operation cancelled" if cancelled? end |