std.concurrent.queue

->timeunit

added in 3.0

(->timeunit obj)

returns the timeunit

(q/->timeunit :ms) => java.util.concurrent.TimeUnit/MILLISECONDS

deque

added in 3.0

(deque)(deque & elements)

constructs a blocking deque

(q/deque 1 2 3) => java.util.concurrent.LinkedBlockingDeque

deque?

added in 3.0

(deque? obj)

checks if object is a BlockingDeque

drain

added in 3.0

(drain queue)(drain queue max)(drain queue max target)

drains elements to another vector

((juxt #(q/drain % 2) #(into [] %)) (q/queue 1 2 3 4)) => [1 2 3 4]

peek

added in 3.0

(peek queue)

takes element at the front of the queue

(q/peek (q/queue))

peek-first

added in 3.0

(peek-first queue)

peeks from the front of the queue

peek-last

added in 3.0

(peek-last queue)

peeks from the back of the queue

pop

added in 3.0

(pop queue)

pops from the front of the queue

process-bulk

added in 3.0

(process-bulk f queue maximum)

processes elements in the queue

(def +state+ (atom []))

(q/process-bulk (fn elems(swap! +state+ conj elems)) (q/queue 1 2 3 4 5) 3)

@+state+ => [1 2 3 4 5]

push

added in 3.0

(push queue element)

puts at the front of the queue

put

added in 3.0

(put queue element)(put queue element timeout)(put queue element timeout timeunit)

puts an element at the back

(->> (doto (q/queue) (q/put 1)) (into [])) => 1

put-first

added in 3.0

(put-first queue element)(put-first queue element timeout)(put-first queue element timeout timeunit)

puts at the front of the queue

put-last

added in 3.0

(put-last queue element)(put-last queue element timeout)(put-last queue element timeout timeunit)

puts at the back of the queue

queue

added in 3.0

(queue)(queue & elements)

constructs a blocking queue

(q/queue 1 2 3) => java.util.concurrent.LinkedBlockingQueue

queue:fixed

added in 3.0

(queue:fixed size)

constructs a fixed size blocking queue

(type (q/queue:fixed 10)) => java.util.concurrent.ArrayBlockingQueue

queue:limited

added in 3.0

(queue:limited size)

constructs a limited queue

(q/queue:limited 10)

queue?

added in 3.0

(queue? obj)

checks if object is a BlockingQueue

remaining-capacity

added in 3.0

(remaining-capacity queue)

returns the remaining capacity

(q/remaining-capacity (q/queue)) => 2147483647

(q/remaining-capacity (doto (q/queue:fixed 2) (q/put 1))) => 1

remove

added in 3.0

(remove queue obj)

removes element from queue

take

added in 3.0

(take queue)(take queue timeout)(take queue timeout timeunit)

takes an element from the queue

((juxt q/take #(into [] %)) (q/queue 1 2 3)) => [1 2 3]

take-first

added in 3.0

(take-first queue)(take-first queue timeout)(take-first queue timeout timeunit)

takes from the front of the queue

take-last

added in 3.0

(take-last queue)(take-last queue timeout)(take-last queue timeout timeunit)

takes from the back of the queue