You're viewing version 1.2.0 of future-cancelled?. The latest stable version of Clojure Core is 1.3.0.
1.2.0 Arrow_down_16x16

future-cancelled?

clojure.core

  • (future-cancelled? f)
Returns true if future f is cancelled

2 Examples top

  • user=> (def f (future (inc 0)))                    
    #'user/f
    
    user=> (future-cancel f)       
    false
    
    user=> (future-cancelled? f)
    false
    
    user=> (future-done? f)        
    true
    
    user=> @f                                          
    1
    
  • user=> (def f (future (Thread/sleep 5000) (inc 0)))
    #'user/f
    
    user=> (future-cancel f)                           
    true
    
    user=> (future-cancelled? f)                       
    true
    
    user=> (future-done? f)                            
    true
    
    user=> @f                                          
    java.util.concurrent.CancellationException (NO_SOURCE_FILE:0)
Log in to add / edit an example.

See Also top

Log in to add a see also.

Plus_12x12 Minus_12x12 Source clojure/core.clj:5421 top

(defn future-cancelled?
  "Returns true if future f is cancelled"
  {:added "1.1"}
  [^java.util.concurrent.Future f] (.isCancelled f))
Vars in clojure.core/future-cancelled?: defn
Used in 0 other vars

Comments top

No comments for future-cancelled?. Log in to add a comment.