git clone 'https://github.com/fukamachi/legion.git'
Jesus asked him, “What is your name?” And he said, “My name is Legion, for we are many.” ── Gospel of Mark chapter 5, verse 9
(defparameter *worker* (make-worker (let ((out *standard-output*)) (lambda (worker) (multiple-value-bind (val existsp) (next-job worker) (format out "Processed: ~S~%" val)))))) (start-worker *worker*) (add-job *worker* 10) (add-job *worker* "Hi") (stop-worker *worker*)
(defparameter *cluster* (make-cluster 4 (let ((out *standard-output*)) (lambda (worker) (multiple-value-bind (val existsp) (next-job worker) (format out "Processed: ~S~%" val)))))) (start-cluster *cluster*) (add-job *cluster* 10) (add-job *cluster* "Hi") (stop-cluster *cluster*)
NOTE: Cluster doesn't guarantee the order of processing jobs.
Base structure class of workers.
Create and return a worker thread which has a fixed-length queue.
process-fn is a funcallable object which takes a single value.
You can specify the value by specifying
:queue-size. The default value is
Return the worker's status which is specifically one of
Return the number of outstanding jobs of the
Start the given
worker to process jobs.
Stop the given
worker after processing its queued jobs.
Stop the given
worker immediately (outstanding jobs will be remained in its queue).
Enqueue a new job
val which will be passed to a function specified for
Dequeue a job from
Base structure class of clusters.
Create and return a cluster with
worker-num workers with
You can specify a
scheduler function which takes exact 2 arguments – workers and a job – for task-scheduling. The default is round-robin scheduler.
Return the cluster's status which is one of
Start workers of
Return workers of
cluster in simple-array.
Copyright (c) 2015 Eitaro Fukamachi (firstname.lastname@example.org)
Licensed under the BSD 2-Clause License.