The legion Reference Manual

Table of Contents

Next: , Previous: , Up: (dir)   [Contents][Index]

The legion Reference Manual

This is the legion Reference Manual, version 0.1.1, generated automatically by Declt version 2.3 "Robert April" on Wed Mar 14 04:07:35 2018 GMT+0.


Next: , Previous: , Up: Top   [Contents][Index]

1 Introduction

Legion

Build Status Coverage Status

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

Usage

Worker

(defparameter *worker*
  (make-worker
    (lambda (job)
      (format t "Processed: ~S~%" job))))

(start *worker*)

(add-job *worker* 10)
(add-job *worker* "Hi")

(stop *worker*)

Cluster

(defparameter *cluster*
  (make-cluster 4
    (lambda (job)
      (format t "Processed: ~S~%" job))))

(start *cluster*)

(add-job *cluster* 10)
(add-job *cluster* "Hi")

(stop *cluster*)

NOTE: Cluster doesn't guarantee the order of processing jobs.

Functions

[Class] worker

Base class of workers.

You can specify the value by specifying :queue.

[Function] (worker-status worker)

Return the worker's status which is specifically one of :running, :idle, :shutting and :shutdown.

[Function] (worker-queue-count worker)

Return the number of outstanding jobs of the worker.

[Method] (start worker-or-cluster)

Start the given worker or cluster to process jobs.

[Method] (stop worker-or-cluster)

Stop the given worker or cluster after processing its queued jobs.

[Method] (kill worker-or-cluster)

Stop the given worker or cluster immediately (outstanding jobs will be remained in its queue).

[Method] (add-job worker-or-cluster val)

Enqueue a new job val which will be passed to a function specified for make-worker.

[Method] (fetch-job worker) => val, existsp

Dequeue a job from worker's queue.

[Class] cluster

Base class of clusters.

[Function] (cluster-status cluster)

Return the cluster's status which is one of :running, :shutting and :shutdown.

[Function] (start-cluster cluster)

Start workers of cluster.

[Function] (cluster-workers cluster) => workers-array

Return workers of cluster in simple-array.

Author

Copyright

Copyright (c) 2015 Eitaro Fukamachi (e.arrows@gmail.com)

License

Licensed under the BSD 3-Clause License.


Next: , Previous: , Up: Top   [Contents][Index]

2 Systems

The main system appears first, followed by any subsystem dependency.


Next: , Previous: , Up: Systems   [Contents][Index]

2.1 legion

Author

Eitaro Fukamachi

License

BSD 3-Clause

Description

Simple worker threads with a queue.

Version

0.1.1

Dependencies
Source

legion.asd (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.2 legion/main

Dependencies
Source

legion.asd (file)

Component

lisp.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.3 legion/cluster

Dependencies
Source

legion.asd (file)

Component

lisp.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.4 legion/worker

Dependencies
Source

legion.asd (file)

Component

lisp.lisp (file)


Next: , Previous: , Up: Systems   [Contents][Index]

2.5 legion/queue

Dependencies
Source

legion.asd (file)

Component

lisp.lisp (file)


Previous: , Up: Systems   [Contents][Index]

2.6 legion/error

Source

legion.asd (file)

Component

lisp.lisp (file)


Next: , Previous: , Up: Top   [Contents][Index]

3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


Previous: , Up: Files   [Contents][Index]

3.1 Lisp


Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.1 legion.asd

Location

legion.asd

Systems

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.2 legion/main/lisp.lisp

Parent

legion/main (system)

Location

main.lisp

Packages

legion

Exported Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.3 legion/cluster/lisp.lisp

Parent

legion/cluster (system)

Location

cluster.lisp

Packages

legion/cluster

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.4 legion/worker/lisp.lisp

Parent

legion/worker (system)

Location

worker.lisp

Packages

legion/worker

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Lisp files   [Contents][Index]

3.1.5 legion/queue/lisp.lisp

Parent

legion/queue (system)

Location

queue.lisp

Packages

legion/queue

Exported Definitions
Internal Definitions

Previous: , Up: Lisp files   [Contents][Index]

3.1.6 legion/error/lisp.lisp

Parent

legion/error (system)

Location

error.lisp

Packages

legion/error

Exported Definitions

legion-error (condition)


Next: , Previous: , Up: Top   [Contents][Index]

4 Packages

Packages are listed by definition order.


Next: , Previous: , Up: Packages   [Contents][Index]

4.1 legion

Source

lisp.lisp (file)

Nickname

legion/main

Use List

common-lisp

Exported Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.2 legion/cluster

Source

lisp.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.3 legion/worker

Source

lisp.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Next: , Previous: , Up: Packages   [Contents][Index]

4.4 legion/queue

Source

lisp.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

Previous: , Up: Packages   [Contents][Index]

4.5 legion/error

Source

lisp.lisp (file)

Use List

common-lisp

Exported Definitions

legion-error (condition)


Next: , Previous: , Up: Top   [Contents][Index]

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


Next: , Previous: , Up: Definitions   [Contents][Index]

5.1 Exported definitions


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.1 Functions

Function: dequeue QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: enqueue JOB QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: make-cluster WORKER-NUM PROCESS-FN &rest INITARGS
Package

legion

Source

lisp.lisp (file)

Function: make-queue &optional INITIAL-SIZE
Package

legion/queue

Source

lisp.lisp (file)

Function: make-worker PROCESS-FN &rest INITARGS
Package

legion

Source

lisp.lisp (file)

Function: queue-count QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: queue-empty-p QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: wakenup WORKER
Package

legion/worker

Source

lisp.lisp (file)

Function: worker-queue-count WORKER

Return the number of outstanding jobs.

Package

legion/worker

Source

lisp.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.2 Generic functions

Generic Function: add-job WORKER VAL

Enqueue VAL to WORKER’s queue. This returns WORKER when the queueing has been succeeded; otherwise NIL is returned.

Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: add-job (CLUSTER cluster) JOB
Source

lisp.lisp (file)

Method: add-job (WORKER worker) VAL
Generic Function: cluster-status OBJECT
Generic Function: (setf cluster-status) NEW-VALUE OBJECT
Package

legion/cluster

Methods
Method: cluster-status (CLUSTER cluster)

automatically generated reader method

Source

lisp.lisp (file)

Method: (setf cluster-status) NEW-VALUE (CLUSTER cluster)

automatically generated writer method

Source

lisp.lisp (file)

Generic Function: cluster-workers OBJECT
Package

legion/cluster

Methods
Method: cluster-workers (CLUSTER cluster)

automatically generated reader method

Source

lisp.lisp (file)

Generic Function: fetch-job WORKER

Dequeue a value from WORKER’s queue. This returns multiple values – the job and a successed flag.

Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: fetch-job (WORKER worker)
Generic Function: kill WORKER

Stop the given WORKER immediately.
It raises an error if the WORKER is not running.

Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: kill (CLUSTER cluster)
Source

lisp.lisp (file)

Method: kill (WORKER worker)
Generic Function: process-job WORKER JOB
Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: process-job (WORKER worker) JOB
Generic Function: start WORKER

Start the given WORKER.
It raises an error if the WORKER is already running.

Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: start (CLUSTER cluster)
Source

lisp.lisp (file)

Method: start (WORKER worker)
Generic Function: stop WORKER

Stop the given WORKER after processing its queued jobs. It raises an error if the WORKER is not running.

Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: stop (CLUSTER cluster)
Source

lisp.lisp (file)

Method: stop (WORKER worker)
Generic Function: worker-queue OBJECT
Generic Function: (setf worker-queue) NEW-VALUE OBJECT
Package

legion/worker

Methods
Method: worker-queue (WORKER worker)

automatically generated reader method

Source

lisp.lisp (file)

Method: (setf worker-queue) NEW-VALUE (WORKER worker)

automatically generated writer method

Source

lisp.lisp (file)

Generic Function: worker-status OBJECT
Generic Function: (setf worker-status) NEW-VALUE OBJECT
Package

legion/worker

Methods
Method: worker-status (WORKER worker)

automatically generated reader method

Source

lisp.lisp (file)

Method: (setf worker-status) NEW-VALUE (WORKER worker)

automatically generated writer method

Source

lisp.lisp (file)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.3 Conditions

Condition: legion-error ()
Package

legion/error

Source

lisp.lisp (file)

Direct superclasses

error (condition)


Next: , Previous: , Up: Exported definitions   [Contents][Index]

5.1.4 Structures

Structure: queue ()
Package

legion/queue

Source

lisp.lisp (file)

Direct superclasses

structure-object (structure)

Direct slots
Slot: primary
Readers

queue-primary (function)

Writers

(setf queue-primary) (function)

Slot: buffered
Initform

(quote nil)

Readers

queue-buffered (function)

Writers

(setf queue-buffered) (function)

Slot: lock
Initform

(bordeaux-threads:make-lock "queue lock")

Readers

queue-lock (function)

Writers

(setf queue-lock) (function)


Previous: , Up: Exported definitions   [Contents][Index]

5.1.5 Classes

Class: cluster ()
Package

legion/cluster

Source

lisp.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: status
Initform

:shutdown

Readers

cluster-status (generic function)

Writers

(setf cluster-status) (generic function)

Slot: queue
Initargs

:queue

Initform

(legion/queue:make-queue)

Readers

cluster-queue (generic function)

Writers

(setf cluster-queue) (generic function)

Slot: workers
Initargs

:workers

Initform

(quote nil)

Readers

cluster-workers (generic function)

Class: worker ()
Package

legion/worker

Source

lisp.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: status
Initform

:shutdown

Readers

worker-status (generic function)

Writers

(setf worker-status) (generic function)

Slot: queue
Initargs

:queue

Initform

(legion/queue:make-queue)

Readers

worker-queue (generic function)

Writers

(setf worker-queue) (generic function)

Slot: process-fn
Initargs

:process-fn

Readers

worker-process-fn (generic function)

Slot: thread
Readers

worker-thread (generic function)

Slot: wait-lock
Initform

(bordeaux-threads:make-recursive-lock "wait-lock")

Readers

worker-wait-lock (generic function)

Slot: wait-cond
Initform

(bordeaux-threads:make-condition-variable)

Readers

worker-wait-cond (generic function)


Previous: , Up: Definitions   [Contents][Index]

5.2 Internal definitions


Next: , Previous: , Up: Internal definitions   [Contents][Index]

5.2.1 Functions

Function: %make-queue &key (PRIMARY PRIMARY) (BUFFERED BUFFERED) (LOCK LOCK)
Package

legion/queue

Source

lisp.lisp (file)

Function: copy-queue INSTANCE
Package

legion/queue

Source

lisp.lisp (file)

Function: extend QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: need-to-extend-p QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: need-to-tidy-p QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: queue-buffered INSTANCE
Function: (setf queue-buffered) VALUE INSTANCE
Package

legion/queue

Source

lisp.lisp (file)

Function: queue-lock INSTANCE
Function: (setf queue-lock) VALUE INSTANCE
Package

legion/queue

Source

lisp.lisp (file)

Function: queue-p OBJECT
Package

legion/queue

Source

lisp.lisp (file)

Function: queue-primary INSTANCE
Function: (setf queue-primary) VALUE INSTANCE
Package

legion/queue

Source

lisp.lisp (file)

Function: queue-to-enqueue QUEUE
Package

legion/queue

Source

lisp.lisp (file)

Function: tidy QUEUE
Package

legion/queue

Source

lisp.lisp (file)


Previous: , Up: Internal definitions   [Contents][Index]

5.2.2 Generic functions

Generic Function: cluster-queue OBJECT
Generic Function: (setf cluster-queue) NEW-VALUE OBJECT
Package

legion/cluster

Methods
Method: cluster-queue (CLUSTER cluster)

automatically generated reader method

Source

lisp.lisp (file)

Method: (setf cluster-queue) NEW-VALUE (CLUSTER cluster)

automatically generated writer method

Source

lisp.lisp (file)

Generic Function: run WORKER
Package

legion/worker

Source

lisp.lisp (file)

Methods
Method: run (WORKER worker)
Method: run (WORKER worker) around
Generic Function: worker-process-fn OBJECT
Package

legion/worker

Methods
Method: worker-process-fn (WORKER worker)

automatically generated reader method

Source

lisp.lisp (file)

Generic Function: worker-thread OBJECT
Package

legion/worker

Methods
Method: worker-thread (WORKER worker)

automatically generated reader method

Source

lisp.lisp (file)

Generic Function: worker-wait-cond OBJECT
Package

legion/worker

Methods
Method: worker-wait-cond (WORKER worker)

automatically generated reader method

Source

lisp.lisp (file)

Generic Function: worker-wait-lock OBJECT
Package

legion/worker

Methods
Method: worker-wait-lock (WORKER worker)

automatically generated reader method

Source

lisp.lisp (file)


Previous: , Up: Top   [Contents][Index]

Appendix A Indexes


Next: , Previous: , Up: Indexes   [Contents][Index]

A.1 Concepts

Jump to:   F   L  
Index Entry  Section

F
File, Lisp, legion.asd: The legion<dot>asd file
File, Lisp, legion/cluster/lisp.lisp: The legion/cluster/lisp<dot>lisp file
File, Lisp, legion/error/lisp.lisp: The legion/error/lisp<dot>lisp file
File, Lisp, legion/main/lisp.lisp: The legion/main/lisp<dot>lisp file
File, Lisp, legion/queue/lisp.lisp: The legion/queue/lisp<dot>lisp file
File, Lisp, legion/worker/lisp.lisp: The legion/worker/lisp<dot>lisp file

L
legion.asd: The legion<dot>asd file
legion/cluster/lisp.lisp: The legion/cluster/lisp<dot>lisp file
legion/error/lisp.lisp: The legion/error/lisp<dot>lisp file
legion/main/lisp.lisp: The legion/main/lisp<dot>lisp file
legion/queue/lisp.lisp: The legion/queue/lisp<dot>lisp file
legion/worker/lisp.lisp: The legion/worker/lisp<dot>lisp file
Lisp File, legion.asd: The legion<dot>asd file
Lisp File, legion/cluster/lisp.lisp: The legion/cluster/lisp<dot>lisp file
Lisp File, legion/error/lisp.lisp: The legion/error/lisp<dot>lisp file
Lisp File, legion/main/lisp.lisp: The legion/main/lisp<dot>lisp file
Lisp File, legion/queue/lisp.lisp: The legion/queue/lisp<dot>lisp file
Lisp File, legion/worker/lisp.lisp: The legion/worker/lisp<dot>lisp file

Jump to:   F   L  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.2 Functions

Jump to:   %   (  
A   C   D   E   F   G   K   M   N   P   Q   R   S   T   W  
Index Entry  Section

%
%make-queue: Internal functions

(
(setf cluster-queue): Internal generic functions
(setf cluster-queue): Internal generic functions
(setf cluster-status): Exported generic functions
(setf cluster-status): Exported generic functions
(setf queue-buffered): Internal functions
(setf queue-lock): Internal functions
(setf queue-primary): Internal functions
(setf worker-queue): Exported generic functions
(setf worker-queue): Exported generic functions
(setf worker-status): Exported generic functions
(setf worker-status): Exported generic functions

A
add-job: Exported generic functions
add-job: Exported generic functions
add-job: Exported generic functions

C
cluster-queue: Internal generic functions
cluster-queue: Internal generic functions
cluster-status: Exported generic functions
cluster-status: Exported generic functions
cluster-workers: Exported generic functions
cluster-workers: Exported generic functions
copy-queue: Internal functions

D
dequeue: Exported functions

E
enqueue: Exported functions
extend: Internal functions

F
fetch-job: Exported generic functions
fetch-job: Exported generic functions
Function, %make-queue: Internal functions
Function, (setf queue-buffered): Internal functions
Function, (setf queue-lock): Internal functions
Function, (setf queue-primary): Internal functions
Function, copy-queue: Internal functions
Function, dequeue: Exported functions
Function, enqueue: Exported functions
Function, extend: Internal functions
Function, make-cluster: Exported functions
Function, make-queue: Exported functions
Function, make-worker: Exported functions
Function, need-to-extend-p: Internal functions
Function, need-to-tidy-p: Internal functions
Function, queue-buffered: Internal functions
Function, queue-count: Exported functions
Function, queue-empty-p: Exported functions
Function, queue-lock: Internal functions
Function, queue-p: Internal functions
Function, queue-primary: Internal functions
Function, queue-to-enqueue: Internal functions
Function, tidy: Internal functions
Function, wakenup: Exported functions
Function, worker-queue-count: Exported functions

G
Generic Function, (setf cluster-queue): Internal generic functions
Generic Function, (setf cluster-status): Exported generic functions
Generic Function, (setf worker-queue): Exported generic functions
Generic Function, (setf worker-status): Exported generic functions
Generic Function, add-job: Exported generic functions
Generic Function, cluster-queue: Internal generic functions
Generic Function, cluster-status: Exported generic functions
Generic Function, cluster-workers: Exported generic functions
Generic Function, fetch-job: Exported generic functions
Generic Function, kill: Exported generic functions
Generic Function, process-job: Exported generic functions
Generic Function, run: Internal generic functions
Generic Function, start: Exported generic functions
Generic Function, stop: Exported generic functions
Generic Function, worker-process-fn: Internal generic functions
Generic Function, worker-queue: Exported generic functions
Generic Function, worker-status: Exported generic functions
Generic Function, worker-thread: Internal generic functions
Generic Function, worker-wait-cond: Internal generic functions
Generic Function, worker-wait-lock: Internal generic functions

K
kill: Exported generic functions
kill: Exported generic functions
kill: Exported generic functions

M
make-cluster: Exported functions
make-queue: Exported functions
make-worker: Exported functions
Method, (setf cluster-queue): Internal generic functions
Method, (setf cluster-status): Exported generic functions
Method, (setf worker-queue): Exported generic functions
Method, (setf worker-status): Exported generic functions
Method, add-job: Exported generic functions
Method, add-job: Exported generic functions
Method, cluster-queue: Internal generic functions
Method, cluster-status: Exported generic functions
Method, cluster-workers: Exported generic functions
Method, fetch-job: Exported generic functions
Method, kill: Exported generic functions
Method, kill: Exported generic functions
Method, process-job: Exported generic functions
Method, run: Internal generic functions
Method, run: Internal generic functions
Method, start: Exported generic functions
Method, start: Exported generic functions
Method, stop: Exported generic functions
Method, stop: Exported generic functions
Method, worker-process-fn: Internal generic functions
Method, worker-queue: Exported generic functions
Method, worker-status: Exported generic functions
Method, worker-thread: Internal generic functions
Method, worker-wait-cond: Internal generic functions
Method, worker-wait-lock: Internal generic functions

N
need-to-extend-p: Internal functions
need-to-tidy-p: Internal functions

P
process-job: Exported generic functions
process-job: Exported generic functions

Q
queue-buffered: Internal functions
queue-count: Exported functions
queue-empty-p: Exported functions
queue-lock: Internal functions
queue-p: Internal functions
queue-primary: Internal functions
queue-to-enqueue: Internal functions

R
run: Internal generic functions
run: Internal generic functions
run: Internal generic functions

S
start: Exported generic functions
start: Exported generic functions
start: Exported generic functions
stop: Exported generic functions
stop: Exported generic functions
stop: Exported generic functions

T
tidy: Internal functions

W
wakenup: Exported functions
worker-process-fn: Internal generic functions
worker-process-fn: Internal generic functions
worker-queue: Exported generic functions
worker-queue: Exported generic functions
worker-queue-count: Exported functions
worker-status: Exported generic functions
worker-status: Exported generic functions
worker-thread: Internal generic functions
worker-thread: Internal generic functions
worker-wait-cond: Internal generic functions
worker-wait-cond: Internal generic functions
worker-wait-lock: Internal generic functions
worker-wait-lock: Internal generic functions

Jump to:   %   (  
A   C   D   E   F   G   K   M   N   P   Q   R   S   T   W  

Next: , Previous: , Up: Indexes   [Contents][Index]

A.3 Variables

Jump to:   B   L   P   Q   S   T   W  
Index Entry  Section

B
buffered: Exported structures

L
lock: Exported structures

P
primary: Exported structures
process-fn: Exported classes

Q
queue: Exported classes
queue: Exported classes

S
Slot, buffered: Exported structures
Slot, lock: Exported structures
Slot, primary: Exported structures
Slot, process-fn: Exported classes
Slot, queue: Exported classes
Slot, queue: Exported classes
Slot, status: Exported classes
Slot, status: Exported classes
Slot, thread: Exported classes
Slot, wait-cond: Exported classes
Slot, wait-lock: Exported classes
Slot, workers: Exported classes
status: Exported classes
status: Exported classes

T
thread: Exported classes

W
wait-cond: Exported classes
wait-lock: Exported classes
workers: Exported classes

Jump to:   B   L   P   Q   S   T   W  

Previous: , Up: Indexes   [Contents][Index]

A.4 Data types

Jump to:   C   L   P   Q   S   W  
Index Entry  Section

C
Class, cluster: Exported classes
Class, worker: Exported classes
cluster: Exported classes
Condition, legion-error: Exported conditions

L
legion: The legion system
legion: The legion package
legion-error: Exported conditions
legion/cluster: The legion/cluster system
legion/cluster: The legion/cluster package
legion/error: The legion/error system
legion/error: The legion/error package
legion/main: The legion/main system
legion/queue: The legion/queue system
legion/queue: The legion/queue package
legion/worker: The legion/worker system
legion/worker: The legion/worker package

P
Package, legion: The legion package
Package, legion/cluster: The legion/cluster package
Package, legion/error: The legion/error package
Package, legion/queue: The legion/queue package
Package, legion/worker: The legion/worker package

Q
queue: Exported structures

S
Structure, queue: Exported structures
System, legion: The legion system
System, legion/cluster: The legion/cluster system
System, legion/error: The legion/error system
System, legion/main: The legion/main system
System, legion/queue: The legion/queue system
System, legion/worker: The legion/worker system

W
worker: Exported classes

Jump to:   C   L   P   Q   S   W