Common Lisp Package: PCALL

README:

FUNCTION

Public

JOIN (TASK)

Join a task, meaning stop execution of the current thread until the result of the task is available, and then return this result. When this is called on a task that no thread is currently working on, the current thread executes the task directly.

PCALL (THUNK)

Call a thunk in parallel. Returns a task that can be joined. When an exclusive is given, the task will only run when no other tasks with that exclusive are running.

SELECT-ONE (&REST TASKS)

Returns the first task that can be joined without blocking.

Undocumented

DONE-P (TASK)

FINISH-TASKS

SET-WORKER-ENVIRONMENT (WRAPPER)

THREAD-POOL-SIZE

SETFTHREAD-POOL-SIZE (SIZE)

Private

AUDIT-THREAD-POOL

Make sure the thread pool holds the correct amount of live threads.

EXECUTE-TASK (TASK)

Execute a task, and store the result or error in the task object. When a task's status is not :free, that means the joiner has already started executing it, so this thread should leave it alone.

POOL-ENV (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

POOL-LOCK (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

POOL-QUEUE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

POOL-SIZE (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

POOL-THREADS (INSTANCE)

@arg[extid]{A @class{extid}} @return[sytemid]{puri:uri or nil} Returns the System ID part of this External ID.

WORKER-THREAD (QUEUE)

The code running inside the pooled threads. Repeatedly tries to take a task from the queue, and handles it.

Undocumented

COPY-POOL (INSTANCE)

MAKE-POOL (&KEY ((THREADS DUM0) NIL) ((SIZE DUM1) 3) ((LOCK DUM2) (MAKE-LOCK)) ((ENV DUM3) NIL) ((QUEUE DUM4) (MAKE-QUEUE)))

SETFPOOL-ENV (NEW-VALUE INSTANCE)

SETFPOOL-LOCK (NEW-VALUE INSTANCE)

POOL-P (OBJECT)

SETFPOOL-QUEUE (NEW-VALUE INSTANCE)

SETFPOOL-SIZE (NEW-VALUE INSTANCE)

SETFPOOL-THREADS (NEW-VALUE INSTANCE)

SPAWN-THREAD (POOL)

STOP-THREAD (THREAD AT-ONCE-P)

WITH-LOCKS (LOCKS THUNK)

MACRO

Public

PEXEC (&BODY BODY)

Shorthand for pcall.

WITH-LOCAL-THREAD-POOL ((&KEY (SIZE '(POOL-SIZE *POOL*)) (ON-UNWIND WAIT) (WORKER-ENVIRONMENT '(POOL-ENV *POOL*))) &BODY BODY)

Run body with a fresh thread pool. If on-unwind is :wait, it will wait for all tasks to finish before returning. If it is :leave, the form will return while threads are still working. If it is :stop or :destroy, the threads will be stopped at the end of the body. With :stop, they will first finish their current task (if any), with :destroy, they will be brutally destroyed and might leak resources, leave stuff in inconsistent state, etc.

Undocumented

PLET ((&REST BINDINGS) &BODY BODY)

GENERIC-FUNCTION

Private

Undocumented

STOP-AT-ONCE-P (CONDITION)

SLOT-ACCESSOR

Private

Undocumented

TASK-ERROR (OBJECT)

SETFTASK-ERROR (NEW-VALUE OBJECT)

TASK-LOCK (OBJECT)

TASK-STATUS (OBJECT)

SETFTASK-STATUS (NEW-VALUE OBJECT)

TASK-THUNK (OBJECT)

TASK-VALUES (OBJECT)

SETFTASK-VALUES (NEW-VALUE OBJECT)

TASK-WAIT-LOCKS (OBJECT)

SETFTASK-WAIT-LOCKS (NEW-VALUE OBJECT)

TASK-WAITING (OBJECT)

SETFTASK-WAITING (NEW-VALUE OBJECT)

VARIABLE

Private

Undocumented

*POOL*

CLASS

Private

TASK

A task is a piece of code that is scheduled to run in the thread pool.

Undocumented

POOL

CONDITION

Private

Undocumented

STOP-RUNNING