The thread-pool Reference Manual

Table of Contents

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

The thread-pool Reference Manual

This is the thread-pool Reference Manual, version 0.2, generated automatically by Declt version 2.4 "Will Decker" on Wed Jun 20 12:39:57 2018 GMT+0.


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

1 Introduction

PROBLEM=========================================================================
Thread creation is an 'heavy' process.
Too many thrads hurts performance.

SOLUTION========================================================================
thread-pool is a simple library that allows users for asynchronous computation
using only a fixed number of threads optimizing overall performance.

SAMPLE USAGE===================================================================

CL-USER> (require :thread-pool)

CL-USER> (let ((out *standard-output*))
	   (defun make-lazy-fib (n)
	     (labels ((fib (n) (if (> n 2)
                               (+ (fib (- n 1)) (fib (- n 2)))
			       1)))
	       (lambda ()
		 (format out "~%fib ~a = ~a~%" n (fib n))))))

CL-USER> (defvar *pool* (thread-pool:make-thread-pool 3))
*POOL*

CL-USER> (thread-pool:start-pool *pool*)
(#
 #
 #)

CL-USER> (let ((out *standard-output*))
	   (defun make-lazy-fib (n)
	     (flet ((fib (n) (if (> n 2)
				 (+ (fib (- n 1)) (fib (- n 2)))
				 1)))
	       (lambda ()
		 (format out "~%fib ~a = ~a~%" n (fib n))))))
MAKE-LAZY-FIB
CL-USER> (progn (thread-pool:add-to-pool *pool* (make-lazy-fib 15))
		(thread-pool:add-to-pool *pool* (make-lazy-fib 20))
		(thread-pool:add-to-pool *pool* (make-lazy-fib 5))
		(thread-pool:add-to-pool *pool* (make-lazy-fib 17))
		(thread-pool:add-to-pool *pool* (make-lazy-fib 10))
		(thread-pool:add-to-pool *pool* (make-lazy-fib 6)))

(#) 
(# #) 
(# #
 #) 

fib 15 = 610
(# #
 #) 
(# #
 #) 
(# #
 # #) 

fib 5 = 5

fib 20 = 6765

fib 17 = 1597

fib 10 = 55

fib 6 = 8
1

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

2 Systems

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


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

2.1 thread-pool

Author

Andrea Chiumenti

License

Public Domain

Version

0.2

Dependencies
Source

thread-pool.asd (file)

Component

src (module)


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

3 Modules

Modules are listed depth-first from the system components tree.


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

3.1 thread-pool/src

Parent

thread-pool (system)

Location

src/

Components

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

4 Files

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


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

4.1 Lisp


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

4.1.1 thread-pool.asd

Location

thread-pool.asd

Systems

thread-pool (system)


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

4.1.2 thread-pool/src/package.lisp

Parent

src (module)

Location

src/package.lisp

Packages

thread-pool


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

4.1.3 thread-pool/src/thread-pool.lisp

Dependency

package.lisp (file)

Parent

src (module)

Location

src/thread-pool.lisp

Exported Definitions
Internal Definitions

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

5 Packages

Packages are listed by definition order.


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

5.1 thread-pool

A simple thread pool system

Source

package.lisp (file)

Use List

common-lisp

Exported Definitions
Internal Definitions

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

6 Definitions

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


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

6.1 Exported definitions


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

6.1.1 Functions

Function: make-thread-pool &optional POOL-SIZE
Package

thread-pool

Source

thread-pool.lisp (file)


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

6.1.2 Generic functions

Generic Function: add-to-pool THREAD-POOL FUNCTIONS

Add a function or a list of function to the thread pool

Package

thread-pool

Source

thread-pool.lisp (file)

Methods
Method: add-to-pool (THREAD-POOL thread-pool) FUNCTIONS
Generic Function: callable-call CALL
Package

thread-pool

Source

thread-pool.lisp (file)

Methods
Method: callable-call (CALLABLE callable)
Generic Function: callable-handler-func OBJECT
Generic Function: (setf callable-handler-func) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: callable-handler-func (CALLABLE callable)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf callable-handler-func) NEW-VALUE (CALLABLE callable)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: pool-size OBJECT
Generic Function: (setf pool-size) SIZE THREAD-POOL
Package

thread-pool

Methods
Method: pool-size (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf pool-size) SIZE (THREAD-POOL thread-pool)
Source

thread-pool.lisp (file)

Generic Function: start-pool THREAD-POOL

Starts serving jobs

Package

thread-pool

Source

thread-pool.lisp (file)

Methods
Method: start-pool (THREAD-POOL thread-pool)
Generic Function: stop-pool THREAD-POOL

Stops serving jobs

Package

thread-pool

Source

thread-pool.lisp (file)

Methods
Method: stop-pool (THREAD-POOL thread-pool)

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

6.1.3 Classes

Class: callable ()
Package

thread-pool

Source

thread-pool.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: handler-func
Initargs

:handler-func

Readers

callable-handler-func (generic function)

Writers

(setf callable-handler-func) (generic function)


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

6.2 Internal definitions


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

6.2.1 Generic functions

Generic Function: jobs OBJECT
Generic Function: (setf jobs) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: jobs (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf jobs) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: main-thread OBJECT
Generic Function: (setf main-thread) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: main-thread (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf main-thread) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: pool-condition OBJECT
Generic Function: (setf pool-condition) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: pool-condition (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf pool-condition) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: pool-condition-vars OBJECT
Generic Function: (setf pool-condition-vars) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: pool-condition-vars (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf pool-condition-vars) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: pool-lock OBJECT
Generic Function: (setf pool-lock) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: pool-lock (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf pool-lock) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: running-p OBJECT
Generic Function: (setf running-p) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: running-p (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf running-p) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: thread-locks OBJECT
Generic Function: (setf thread-locks) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: thread-locks (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf thread-locks) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)

Generic Function: threads OBJECT
Generic Function: (setf threads) NEW-VALUE OBJECT
Package

thread-pool

Methods
Method: threads (THREAD-POOL thread-pool)

automatically generated reader method

Source

thread-pool.lisp (file)

Method: (setf threads) NEW-VALUE (THREAD-POOL thread-pool)

automatically generated writer method

Source

thread-pool.lisp (file)


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

6.2.2 Classes

Class: thread-pool ()
Package

thread-pool

Source

thread-pool.lisp (file)

Direct superclasses

standard-object (class)

Direct methods
Direct slots
Slot: jobs
Initform

(make-instance (quote it.bese.arnesi:queue))

Readers

jobs (generic function)

Writers

(setf jobs) (generic function)

Slot: pool-size
Initargs

:pool-size

Readers

pool-size (generic function)

Slot: threads
Readers

threads (generic function)

Writers

(setf threads) (generic function)

Slot: thread-locks
Readers

thread-locks (generic function)

Writers

(setf thread-locks) (generic function)

Slot: pool-condition-vars
Readers

pool-condition-vars (generic function)

Writers

(setf pool-condition-vars) (generic function)

Slot: pool-lock
Initform

(bordeaux-threads:make-lock)

Readers

pool-lock (generic function)

Writers

(setf pool-lock) (generic function)

Slot: pool-condition
Initform

(bordeaux-threads:make-condition-variable)

Readers

pool-condition (generic function)

Writers

(setf pool-condition) (generic function)

Slot: running-p
Readers

running-p (generic function)

Writers

(setf running-p) (generic function)

Slot: main-thread
Readers

main-thread (generic function)

Writers

(setf main-thread) (generic function)

Direct Default Initargs
InitargValue
:pool-size1

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

Appendix A Indexes


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

A.1 Concepts

Jump to:   F   L   M   T  
Index Entry  Section

F
File, Lisp, thread-pool.asd: The thread-pool<dot>asd file
File, Lisp, thread-pool/src/package.lisp: The thread-pool/src/package<dot>lisp file
File, Lisp, thread-pool/src/thread-pool.lisp: The thread-pool/src/thread-pool<dot>lisp file

L
Lisp File, thread-pool.asd: The thread-pool<dot>asd file
Lisp File, thread-pool/src/package.lisp: The thread-pool/src/package<dot>lisp file
Lisp File, thread-pool/src/thread-pool.lisp: The thread-pool/src/thread-pool<dot>lisp file

M
Module, thread-pool/src: The thread-pool/src module

T
thread-pool.asd: The thread-pool<dot>asd file
thread-pool/src: The thread-pool/src module
thread-pool/src/package.lisp: The thread-pool/src/package<dot>lisp file
thread-pool/src/thread-pool.lisp: The thread-pool/src/thread-pool<dot>lisp file

Jump to:   F   L   M   T  

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

A.2 Functions

Jump to:   (  
A   C   F   G   J   M   P   R   S   T  
Index Entry  Section

(
(setf callable-handler-func): Exported generic functions
(setf callable-handler-func): Exported generic functions
(setf jobs): Internal generic functions
(setf jobs): Internal generic functions
(setf main-thread): Internal generic functions
(setf main-thread): Internal generic functions
(setf pool-condition): Internal generic functions
(setf pool-condition): Internal generic functions
(setf pool-condition-vars): Internal generic functions
(setf pool-condition-vars): Internal generic functions
(setf pool-lock): Internal generic functions
(setf pool-lock): Internal generic functions
(setf pool-size): Exported generic functions
(setf pool-size): Exported generic functions
(setf running-p): Internal generic functions
(setf running-p): Internal generic functions
(setf thread-locks): Internal generic functions
(setf thread-locks): Internal generic functions
(setf threads): Internal generic functions
(setf threads): Internal generic functions

A
add-to-pool: Exported generic functions
add-to-pool: Exported generic functions

C
callable-call: Exported generic functions
callable-call: Exported generic functions
callable-handler-func: Exported generic functions
callable-handler-func: Exported generic functions

F
Function, make-thread-pool: Exported functions

G
Generic Function, (setf callable-handler-func): Exported generic functions
Generic Function, (setf jobs): Internal generic functions
Generic Function, (setf main-thread): Internal generic functions
Generic Function, (setf pool-condition): Internal generic functions
Generic Function, (setf pool-condition-vars): Internal generic functions
Generic Function, (setf pool-lock): Internal generic functions
Generic Function, (setf pool-size): Exported generic functions
Generic Function, (setf running-p): Internal generic functions
Generic Function, (setf thread-locks): Internal generic functions
Generic Function, (setf threads): Internal generic functions
Generic Function, add-to-pool: Exported generic functions
Generic Function, callable-call: Exported generic functions
Generic Function, callable-handler-func: Exported generic functions
Generic Function, jobs: Internal generic functions
Generic Function, main-thread: Internal generic functions
Generic Function, pool-condition: Internal generic functions
Generic Function, pool-condition-vars: Internal generic functions
Generic Function, pool-lock: Internal generic functions
Generic Function, pool-size: Exported generic functions
Generic Function, running-p: Internal generic functions
Generic Function, start-pool: Exported generic functions
Generic Function, stop-pool: Exported generic functions
Generic Function, thread-locks: Internal generic functions
Generic Function, threads: Internal generic functions

J
jobs: Internal generic functions
jobs: Internal generic functions

M
main-thread: Internal generic functions
main-thread: Internal generic functions
make-thread-pool: Exported functions
Method, (setf callable-handler-func): Exported generic functions
Method, (setf jobs): Internal generic functions
Method, (setf main-thread): Internal generic functions
Method, (setf pool-condition): Internal generic functions
Method, (setf pool-condition-vars): Internal generic functions
Method, (setf pool-lock): Internal generic functions
Method, (setf pool-size): Exported generic functions
Method, (setf running-p): Internal generic functions
Method, (setf thread-locks): Internal generic functions
Method, (setf threads): Internal generic functions
Method, add-to-pool: Exported generic functions
Method, callable-call: Exported generic functions
Method, callable-handler-func: Exported generic functions
Method, jobs: Internal generic functions
Method, main-thread: Internal generic functions
Method, pool-condition: Internal generic functions
Method, pool-condition-vars: Internal generic functions
Method, pool-lock: Internal generic functions
Method, pool-size: Exported generic functions
Method, running-p: Internal generic functions
Method, start-pool: Exported generic functions
Method, stop-pool: Exported generic functions
Method, thread-locks: Internal generic functions
Method, threads: Internal generic functions

P
pool-condition: Internal generic functions
pool-condition: Internal generic functions
pool-condition-vars: Internal generic functions
pool-condition-vars: Internal generic functions
pool-lock: Internal generic functions
pool-lock: Internal generic functions
pool-size: Exported generic functions
pool-size: Exported generic functions

R
running-p: Internal generic functions
running-p: Internal generic functions

S
start-pool: Exported generic functions
start-pool: Exported generic functions
stop-pool: Exported generic functions
stop-pool: Exported generic functions

T
thread-locks: Internal generic functions
thread-locks: Internal generic functions
threads: Internal generic functions
threads: Internal generic functions

Jump to:   (  
A   C   F   G   J   M   P   R   S   T  

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

A.3 Variables

Jump to:   H   J   M   P   R   S   T  
Index Entry  Section

H
handler-func: Exported classes

J
jobs: Internal classes

M
main-thread: Internal classes

P
pool-condition: Internal classes
pool-condition-vars: Internal classes
pool-lock: Internal classes
pool-size: Internal classes

R
running-p: Internal classes

S
Slot, handler-func: Exported classes
Slot, jobs: Internal classes
Slot, main-thread: Internal classes
Slot, pool-condition: Internal classes
Slot, pool-condition-vars: Internal classes
Slot, pool-lock: Internal classes
Slot, pool-size: Internal classes
Slot, running-p: Internal classes
Slot, thread-locks: Internal classes
Slot, threads: Internal classes

T
thread-locks: Internal classes
threads: Internal classes

Jump to:   H   J   M   P   R   S   T  

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

A.4 Data types

Jump to:   C   P   S   T  
Index Entry  Section

C
callable: Exported classes
Class, callable: Exported classes
Class, thread-pool: Internal classes

P
Package, thread-pool: The thread-pool package

S
System, thread-pool: The thread-pool system

T
thread-pool: The thread-pool system
thread-pool: The thread-pool package
thread-pool: Internal classes

Jump to:   C   P   S   T