qbits.knit

binding-conveyor-fn

deref-future

execute

(execute executor f)

Submits the fn to specified executor, returns a Future

executor

(executor type)(executor type {:keys [thread-factory num-threads], :or {num-threads (int 1), thread-factory (Executors/defaultThreadFactory)}})

Returns ExecutorService. type can be :single, :cached, :fixed or :scheduled, this matches the corresponding Java instances

future

macro

(future options & body)

Takes an executor instance and a body of expressions and yields a future object that will invoke the body in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block, unless the variant of deref with timeout is used..

future-call

added in 1.1

(future-call f)(future-call f {:as options, :keys [executor preserve-bindings?], :or {preserve-bindings? true, executor clojure.lang.Agent/soloExecutor}})

Takes a function of no args and yields a future object that will invoke the function in another thread, and will cache the result and return it on all subsequent calls to deref/@. If the computation has not yet finished, calls to deref/@ will block, unless the variant of deref with timeout is used. See also - realized?.

schedule

(schedule type delay f)(schedule type delay f {:keys [executor initial-delay unit], :or {executor (qbits.knit/executor :scheduled), initial-delay 0, unit :milliseconds}})

Return a ScheduledFuture. type can be :with-fixed-delay, :at-fixed-rate, :once delay’s default unit is milliseconds f task (function) to be run

thread

macro

(thread opts & body)

Same as thread but takes an option map first: :executor - An executor that implements clojure.core.async.impl.protocols/Executor

thread-call

(thread-call f)(thread-call f {:keys [executor]})

Executes f in another thread, returning immediately to the calling thread. An optional second argument allows to pass an executor that implements clojure.core.async.impl.protocols/Executor. Returns a channel which will receive the result of calling f when completed.

thread-factory

(thread-factory {:keys [daemon thread-group], :or {daemon true}})

Returns a new ThreadFactory instance

thread-group

(thread-group parent name)(thread-group name)

Returns a new ThreadGroup instance to be used in thread-factory

thread-macro-executor

time-units