std.lib.future
fulfil
added in 3.0
(fulfil future f)(fulfil future f print)(fulfil future f print skip-success)future
macro
added in 3.0
(future)(future opts? & body)constructs a completable future
@(future (Thread/sleep 100) 1) => 1
future:call
added in 3.0
(future:call obj)(future:call obj {:keys [pool delay], :as m})can create a future from a function or :init/future
@(future:call (fn [] 1)) => 1
@(-> (future:fn (fn [] 1)) (future:call)) => 1
future:cancelled?
added in 3.0
(future:cancelled? future)checks if future has been cancelled
future:chain
added in 3.0
(future:chain future chain)(future:chain future chain marr)chains a set of functions
@(future:chain (completed 1) inc inc inc) => 4
@(future:chain (failed (ex-info “ERROR” {})) inc inc inc) => (throws)
future:complete?
added in 3.0
(future:complete? future)checks that future has successfully completed
future:dependents
added in 3.0
(future:dependents future)returns number of steps waiting on current result
future:done
macro
added in 3.0
(future:done future & body)helper macro for status functions
future:exception
added in 3.0
(future:exception future)accesses the exception in the future
future:exception?
added in 3.0
(future:exception? future)checks if future raised an exception
future:fn
added in 3.0
(future:fn f)(future:fn f {:keys [pool timeout delay default], :as m})creates a future with :init/future props
future:force
added in 3.0
(future:force future object)(future:force future type object)forces a value or exception as completed future
future:incomplete?
added in 3.0
(future:incomplete? future)check that future is incomplete
(-> (incomplete) (future:incomplete?)) => true
future:now
added in 3.0
(future:now future)(future:now future default)gets the value of a future at the current moment
future:obtrude
added in 4.0
(future:obtrude future object)(future:obtrude future type object)like force but uses obtrude and obtrudeException
future:result
added in 3.0
(future:result future)gets the result of the future
(future:result (completed 1)) => {:status :success, :data 1, :exception nil}
(future:result (failed (ex-info "" {}))) => (contains {:status :error :data nil :exception Throwable})
future:run
added in 3.0
(future:run obj)(future:run obj {:keys [pool delay timeout default], :as m})runs a function with additional settings
(future:run (fn [](Thread/sleep 100)) {:timeout 10 :default :ok :delay 100 :pool :async})
future:status
added in 3.0
(future:status future)retrieves a status of either :success, :error or waiting
future:timeout
added in 3.0
(future:timeout future interval)(future:timeout future interval default)adds a timeout to the completed future
@(-> (future:call (fn [](Thread/sleep 100))) (future:timeout 10 :ok)) => :ok
future:timeout?
added in 3.0
(future:timeout? future)checks if future errored due to timeout
future:wait
added in 3.0
(future:wait future)(future:wait future interval)waits for future to finish or
(-> (future:call (fn [](Thread/sleep 100))) (future:timeout 10 :ok) (future:wait) (future:now)) => :ok
future?
added in 3.0
(future? obj)checks if object is CompleteableFuture
(future? (future 1)) => true
incomplete
added in 3.0
(incomplete)creates an incomplete stage (like promise)
(incomplete) => (comp not future:complete?)
on:all
added in 3.0
(on:all futures)(on:all futures f)(on:all futures f {:keys [timeout pool default delay], :as m})calls a function when all futures are complete
on:any
added in 3.0
(on:any futures f)(on:any futures f {:keys [timeout pool default delay], :as m})calls a function when any future is completed
on:cancel
added in 3.0
(on:cancel future f)(on:cancel future f m)processes a function on cancel
on:complete
added in 3.0
(on:complete future f)(on:complete future f {:keys [timeout pool default delay], :as m})process both the value and exception
on:exception
added in 3.0
(on:exception future f)(on:exception future f {:keys [timeout pool default delay], :as m})process a function on exception
on:success
added in 3.0
(on:success future f)(on:success future f {:keys [timeout pool default delay], :as m})processes another step given successful operation
on:timeout
added in 3.0
(on:timeout future f)(on:timeout future f {:keys [timeout pool default delay], :as m})processes a function on timeout
then
macro
added in 3.0
(then future bindings & body)shortcut for :on/success and :on/complete