Skip to content

Commit

Permalink
Implement Future#cancel
Browse files Browse the repository at this point in the history
  • Loading branch information
halorgium committed May 9, 2013
1 parent 09125dc commit b2703c7
Showing 1 changed file with 9 additions and 0 deletions.
9 changes: 9 additions & 0 deletions lib/celluloid/future.rb
Expand Up @@ -84,6 +84,7 @@ def value(timeout = nil)

# Signal this future with the given result value
def signal(value)
return if @cancelled
result = Result.new(value, self)

@mutex.synchronize do
Expand All @@ -99,6 +100,14 @@ def signal(value)
end
alias_method :<<, :signal

def cancel(error)
response = ErrorResponse.new(@call, error)
signal response
@mutex.synchronize do
@cancelled = true
end
end

# Inspect this Celluloid::Future
alias_method :inspect, :to_s

Expand Down

0 comments on commit b2703c7

Please sign in to comment.