std.concurrent.executor

exec:at-capacity?

added in 3.0

(exec:at-capacity? executor)

checks if executor is at capacity

exec:await-termination

added in 3.0

(exec:await-termination service)(exec:await-termination service ms)

await termination for executor service

exec:current-active

added in 3.0

(exec:current-active service)

returns number of active threads in pool

exec:current-completed

added in 3.0

(exec:current-completed service)

returns number of completed tasks

exec:current-size

added in 3.0

(exec:current-size service)

returns number of threads in pool

exec:current-submitted

added in 3.0

(exec:current-submitted service)

returns number of submitted tasks

exec:get-queue

added in 3.0

(exec:get-queue service)

gets the queue from the executor

(-> (executor:pool 10 10 1000 (q/queue)) (exec:get-queue))

exec:increase-capacity

added in 3.0

(exec:increase-capacity executor)(exec:increase-capacity executor n)

increases the capacity of the executor

exec:keep-alive

added in 3.0

(exec:keep-alive service)(exec:keep-alive service length)

gets and sets the keep alive time

exec:pool-max

added in 3.0

(exec:pool-max service)(exec:pool-max service size)

gets and sets the core pool max

exec:pool-size

added in 3.0

(exec:pool-size service)(exec:pool-size service size)

gets and sets the core pool size

exec:queue

added in 3.0

(exec:queue)(exec:queue arg)

contructs a raw queue in different ways

(exec:queue)

(exec:queue 1)

(exec:queue {:size 1})

(exec:queue {})

(exec:queue (q/queue))

exec:rejected-handler

added in 3.0

(exec:rejected-handler service)(exec:rejected-handler service f)

sets the rejected task handler

exec:shutdown

added in 3.0

(exec:shutdown service)

shuts down executor

exec:shutdown-now

added in 3.0

(exec:shutdown-now service)

shuts down executor immediately

exec:shutdown?

added in 3.0

(exec:shutdown? service)

checks if executor is shutdown

exec:terminated?

added in 3.0

(exec:terminated? service)

checks if executor is shutdown and all threads have finished

exec:terminating?

added in 3.0

(exec:terminating? service)

check that executor is terminating

executor

multimethod

added in 3.0

creates an executor

(executor {:type :pool :size 3 :max 3 :keep-alive 1000})

executor:cached

added in 3.0

(executor:cached)

creates a cached executor

(executor:cached)

executor:health

added in 3.0

(executor:health executor)

returns health of the executor

executor:info

added in 3.0

(executor:info executor)(executor:info executor k)

returns executor service info

executor:kill

executor:pool

added in 3.0

(executor:pool size max keep-alive)(executor:pool size max keep-alive size-or-queue)

constructs a pool executor

(executor:pool 10 10 1000 {:size 10})

executor:props

added in 3.0

(executor:props executor)

returns props for getters and setters

executor:scheduled

added in 3.0

(executor:scheduled size)

constructs a scheduled executor

(executor:scheduled 10)

executor:share

added in 3.0

(executor:share id executor)

registers a shared executor

executor:shared

added in 3.0

(executor:shared)

lists all shared executors

(-> (executor:shared) keys sort) => :async :default :pooled

executor:single

added in 3.0

(executor:single)(executor:single size-or-queue)

constructs a single executor

;; any sized pool (executor:single)

;; fixed pool (executor:single {:size 10})

executor:start

executor:started?

executor:stop

executor:stopped?

executor:submit

executor:type

added in 3.0

(executor:type executor)

returns executor service type

executor:unshare

added in 3.0

(executor:unshare id)

deregisters a shared executor

schedule

added in 3.0

(schedule service f interval)(schedule service f interval {:keys [min]})

schedules task for execution

schedule:fixed-delay

added in 3.0

(schedule:fixed-delay service f delay)(schedule:fixed-delay service f delay {:keys [initial min]})

schedules task at fixed delay

schedule:fixed-rate

added in 3.0

(schedule:fixed-rate service f interval)(schedule:fixed-rate service f interval {:keys [initial min]})

schedules task at a fixed rate

submit

added in 3.0

(submit service f)(submit service f {:keys [min max delay default], :as m})

submits a task to an executor

@(submit (executor:single) (fn []) {:min 100}) ^hidden

@(submit (executor:single) (fn [] (Thread/sleep 1000)) {:max 100}) => (throws)

submit-notify

added in 3.0

(submit-notify service f)(submit-notify service f {:keys [min max delay default], :as m})

submits a task (generally to a fixed size queue)

(doto (executor:single 1) (submit-notify (fn []) 1000) (submit-notify (fn []) 1000) (submit-notify (fn []) 1000))

wrap-min-time

added in 3.0

(wrap-min-time f total)(wrap-min-time f total delay)

wraps a function with min-time and delay

((wrap-min-time (fn []) 20 0))

((wrap-min-time (fn []) 100 10))