Common Lisp Package: LPARALLEL.KERNEL

Encompasses the scheduling and execution of parallel tasks using a pool of worker threads. All parallelism in lparallel is done on top of the kernel.

README:

FUNCTION

Public

CANCEL-TIMEOUT (TIMEOUT TIMEOUT-RESULT)

Attempt to cancel a timeout. If successful, the channel passed to `submit-timeout' will receive `timeout-result'. At most one call to `cancel-timeout' will succeed; others will be ignored. If the timeout has expired on its own then `cancel-timeout' will have no effect. `cancel-timeout' is not available in ABCL.

CHECK-KERNEL

Ensures the value of `*kernel*' is a kernel instance. Provides the MAKE-KERNEL and STORE-VALUE restarts. Returns `*kernel*'.

END-KERNEL (&KEY WAIT)

Sets `*kernel*' to nil and ends all workers gracefully. `end-kernel' should not be used as a substitute for properly waiting on tasks with `receive-result' or otherwise. If `wait' is nil (the default) then `end-kernel' returns immediately. Workers are waited upon by a separate shutdown manager thread. If `wait' is non-nil then `end-kernel' blocks until all workers are finished. No shutdown manager thread is created. A list of the implementation-defined worker thread objects is returned. If `wait' is nil then the shutdown manager thread is also returned as the first element in the list. Note that creating and destroying kernels is relatively expensive. A kernel typically exists for lifetime of the Lisp process. Having more than one kernel is fine -- simply use `let' to bind a kernel instance to `*kernel*' when you need it. Use `kill-tasks' to terminate deadlocked or infinite looping tasks.

INVOKE-TRANSFER-ERROR (ERROR)

Equivalent to (invoke-restart 'transfer-error error). This is a convenience function for use in `task-handler-bind'.

KERNEL-BINDINGS

Return the bindings passed to `make-kernel'.

KERNEL-CONTEXT

Return the context passed to `make-kernel'.

KERNEL-NAME

Return the name passed to `make-kernel'.

KERNEL-WORKER-COUNT

Return the number of workers in the current kernel.

KILL-TASKS (TASK-CATEGORY &KEY DRY-RUN)

This is an expensive function which should only be used in exceptional circumstances. Every task has an associated task category. When a task is submitted, it is assigned the category of `*task-category*' which has a default value of `:default'. `kill-tasks' interrupts running tasks whose category is `eql' to `task-category'. The corresponding worker threads are killed and replaced. Pending tasks are not affected. If you don't know what to pass for `task-category' then you should probably pass `:default', though this may kill more tasks than you wish. Binding `*task-category*' around `submit-task' enables targeted task killing. If `dry-run' is nil, the function returns the number of tasks killed. If `dry-run' is non-nil then no tasks are killed. In this case the return value is the number of tasks that would have been killed if `dry-run' were nil. `kill-tasks' is not available in ABCL.

MAKE-CHANNEL (&REST ARGS)

Create a channel for submitting and receiving tasks. The current value of `*kernel*' is stored for use in `submit-task'. By default there is no limit on the channel capacity. Passing a `fixed-capacity' keyword argument limits the capacity to the value passed. Note that a fixed capacity channel may cause a deadlocked kernel if `receive-result' is not called a sufficient number of times.

MAKE-KERNEL (WORKER-COUNT &KEY (NAME lparallel) (BINDINGS `((*STANDARD-OUTPUT* ,@*STANDARD-OUTPUT*) (*ERROR-OUTPUT* ,@*ERROR-OUTPUT*))) (CONTEXT #'FUNCALL) (SPIN-COUNT *KERNEL-SPIN-COUNT*))

Create a kernel with `worker-count' number of worker threads. `name' is a string identifier for this kernel which is reported by `print-object'. Worker threads will also be given this name, shown in `bordeaux-threads:all-threads'. `bindings' is an alist for establishing thread-local variables inside worker threads. By default workers will have *standard-output* and *error-output* bindings. Dynamic context for each worker may be established with the function `context'. The argument passed to `context' is a function which must be funcalled. It begins the worker loop and will not return until the worker exits. The default value of `context' is #'funcall. The special variables in `bindings' are available inside the `context' function. When a worker discovers that no tasks are available, `spin-count' is the number of task-searching iterations done by the worker before sleeping. A kernel will not be garbage collected until `end-kernel' is called.

RECEIVE-RESULT (CHANNEL)

Remove a result from `channel'. If nothing is available the call will block until a result is received.

SUBMIT-TASK (CHANNEL FUNCTION &REST ARGS)

Submit a task through `channel' to the kernel stored in `channel'.

SUBMIT-TIMEOUT (CHANNEL TIMEOUT-SECONDS TIMEOUT-RESULT)

Effectively equivalent to (submit-task channel (lambda () (sleep timeout-seconds) timeout-result)) The difference is that `submit-timeout' does not occupy a worker thread. A timeout object is returned, which may be passed to `cancel-timeout'.

TASK-CATEGORIES-RUNNING

Return a vector containing the task category currently running for each worker.

TRY-RECEIVE-RESULT (CHANNEL)

Non-blocking version of `receive-result'. If a result is available then it is returned as the primary value in (values result t). Otherwise (values nil nil) is returned.

Private

%%%%.CHANNEL.KERNEL (INSTANCE)

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

%%%%.CHANNEL.QUEUE (INSTANCE)

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

%%%%.KERNEL.ALIVEP (INSTANCE)

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

%%%%.KERNEL.OPTIMIZER-DATA (INSTANCE)

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

%%%%.KERNEL.OPTIMIZER-FLAG (INSTANCE)

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

%%%%.KERNEL.SCHEDULER (INSTANCE)

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

%%%%.KERNEL.WORKER-INFO (INSTANCE)

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

%%%%.KERNEL.WORKERS (INSTANCE)

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

%%%%.KERNEL.WORKERS-LOCK (INSTANCE)

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

%%%%.OPTIMIZER.OPTIMIZER-DATA (INSTANCE)

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

%%%%.OPTIMIZER.OPTIMIZER-FLAG (INSTANCE)

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

%%%%.SCHEDULER.LOW-PRIORITY-TASKS (INSTANCE)

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

%%%%.SCHEDULER.NOTIFY-COUNT (INSTANCE)

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

%%%%.SCHEDULER.RANDOM-INDEX (INSTANCE)

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

%%%%.SCHEDULER.SPIN-COUNT (INSTANCE)

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

%%%%.SCHEDULER.WAIT-COUNT (INSTANCE)

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

%%%%.SCHEDULER.WAIT-CVAR (INSTANCE)

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

%%%%.SCHEDULER.WAIT-LOCK (INSTANCE)

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

%%%%.SCHEDULER.WORKERS (INSTANCE)

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

%%%%.TIMEOUT.CANCELED-RESULT (INSTANCE)

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

%%%%.TIMEOUT.LOCK (INSTANCE)

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

%%%%.TIMEOUT.THREAD (INSTANCE)

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

%%%%.WORKER-INFO.BINDINGS (INSTANCE)

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

%%%%.WORKER-INFO.CONTEXT (INSTANCE)

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

%%%%.WORKER-INFO.NAME (INSTANCE)

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

%%%%.WORKER-NOTIFICATIONS.EXIT-NOTIFICATION (INSTANCE)

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

%%%%.WORKER-NOTIFICATIONS.HANDSHAKE/FROM-WORKER (INSTANCE)

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

%%%%.WORKER-NOTIFICATIONS.HANDSHAKE/TO-WORKER (INSTANCE)

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

%%%%.WORKER.EXIT-NOTIFICATION (INSTANCE)

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

%%%%.WORKER.HANDSHAKE/FROM-WORKER (INSTANCE)

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

%%%%.WORKER.HANDSHAKE/TO-WORKER (INSTANCE)

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

%%%%.WORKER.INDEX (INSTANCE)

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

%%%%.WORKER.RUNNING-CATEGORY (INSTANCE)

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

%%%%.WORKER.TASKS (INSTANCE)

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

%%%%.WORKER.THREAD (INSTANCE)

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

%%%%.WRAPPED-ERROR.CONDITION (INSTANCE)

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

ALIVEP (INSTANCE)

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

CHANNEL-KERNEL (INSTANCE)

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

CHANNEL-QUEUE (INSTANCE)

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

CONDITION-HANDLER (CONDITION)

Mimic the CL handling mechanism, calling handlers until one assumes control (or not).

MAKE-DEBUGGER-HOOK

Record `*debugger-error*' for the `transfer-error' restart.

OPTIMIZER-DATA (INSTANCE)

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

OPTIMIZER-FLAG (INSTANCE)

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

RUNNING-CATEGORY (INSTANCE)

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

SCHEDULER (INSTANCE)

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

TASK-CATEGORY (LIST)

Return all but the first object in a list.

TASK-FN (LIST)

Return the 1st object in a list.

TASKS (INSTANCE)

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

THREAD (INSTANCE)

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

UNWRAP-RESULT (RESULT)

In `receive-result', this is called on the stored task result. The user receives the return value of this function.

WORKER-INDEX (INSTANCE)

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

WORKERS (INSTANCE)

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

WRAP-ERROR (CONDITION)

Wrap an error. A non-error condition may also be wrapped, though it will still be signaled with `error'.

Undocumented

SETF%%%%.CHANNEL.KERNEL (NEW-VALUE INSTANCE)

SETF%%%%.CHANNEL.QUEUE (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.ALIVEP (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.OPTIMIZER-DATA (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.OPTIMIZER-FLAG (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.SCHEDULER (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.WORKER-INFO (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.WORKERS (NEW-VALUE INSTANCE)

SETF%%%%.KERNEL.WORKERS-LOCK (NEW-VALUE INSTANCE)

SETF%%%%.OPTIMIZER.OPTIMIZER-DATA (NEW-VALUE INSTANCE)

SETF%%%%.OPTIMIZER.OPTIMIZER-FLAG (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.LOW-PRIORITY-TASKS (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.NOTIFY-COUNT (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.RANDOM-INDEX (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.SPIN-COUNT (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.WAIT-COUNT (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.WAIT-CVAR (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.WAIT-LOCK (NEW-VALUE INSTANCE)

SETF%%%%.SCHEDULER.WORKERS (NEW-VALUE INSTANCE)

SETF%%%%.TIMEOUT.CANCELED-RESULT (NEW-VALUE INSTANCE)

SETF%%%%.TIMEOUT.LOCK (NEW-VALUE INSTANCE)

SETF%%%%.TIMEOUT.THREAD (NEW-VALUE INSTANCE)

SETF%%%%.WORKER-INFO.BINDINGS (NEW-VALUE INSTANCE)

SETF%%%%.WORKER-INFO.CONTEXT (NEW-VALUE INSTANCE)

SETF%%%%.WORKER-INFO.NAME (NEW-VALUE INSTANCE)

SETF%%%%.WORKER-NOTIFICATIONS.EXIT-NOTIFICATION (NEW-VALUE INSTANCE)

SETF%%%%.WORKER-NOTIFICATIONS.HANDSHAKE/FROM-WORKER (NEW-VALUE INSTANCE)

SETF%%%%.WORKER-NOTIFICATIONS.HANDSHAKE/TO-WORKER (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.EXIT-NOTIFICATION (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.HANDSHAKE/FROM-WORKER (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.HANDSHAKE/TO-WORKER (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.INDEX (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.RUNNING-CATEGORY (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.TASKS (NEW-VALUE INSTANCE)

SETF%%%%.WORKER.THREAD (NEW-VALUE INSTANCE)

SETF%%%%.WRAPPED-ERROR.CONDITION (NEW-VALUE INSTANCE)

%CALL-WITH-TASK-HANDLER (FN)

%KERNEL-WORKER-COUNT

%MAKE-CHANNEL (&KEY FIXED-CAPACITY)

%MAKE-WORKER (INDEX TASKS)

%MAKE-WORKERS (KERNEL WORKER-VECTOR)

CALL-WITH-TASK-HANDLER

CALL-WITH-WORKER-CONTEXT (FN WORKER-CONTEXT KERNEL WORKER)

CHANNEL-P (OBJECT)

COPY-CHANNEL (INSTANCE)

COPY-KERNEL (INSTANCE)

COPY-OPTIMIZER (INSTANCE)

COPY-SCHEDULER (INSTANCE)

COPY-TIMEOUT (INSTANCE)

COPY-WORKER (INSTANCE)

COPY-WORKER-INFO (INSTANCE)

COPY-WORKER-NOTIFICATIONS (INSTANCE)

COPY-WRAPPED-ERROR (INSTANCE)

ENTER-WORKER-LOOP (KERNEL WORKER)

EXEC-TASK/NON-WORKER

EXEC-TASK/WORKER

HANDSHAKE/FROM-WORKER/FINISH (WORKER STATUS)

HANDSHAKE/FROM-WORKER/START (WORKER)

HANDSHAKE/TO-WORKER/FINISH (WORKER)

HANDSHAKE/TO-WORKER/START (WORKER)

KERNEL-INFO (KERNEL)

KERNEL-P (OBJECT)

KILL (KERNEL CATEGORY)

KILL-ERRORS

KILL-ERRORS-REPORT (STREAM)

MAKE-ALL-BINDINGS (KERNEL BINDINGS)

MAKE-CHANNEL-INSTANCE (&KEY ((QUEUE DUM492) (ERROR slot ~a in ~a not initialized 'QUEUE 'CHANNEL)) ((KERNEL DUM493) (ERROR slot ~a in ~a not initialized 'KERNEL 'CHANNEL)))

MAKE-CHANNELED-TASK (CHANNEL FN ARGS)

MAKE-KERNEL-INSTANCE (&KEY ((OPTIMIZER-FLAG DUM359) T) ((OPTIMIZER-DATA DUM360) (ERROR slot ~a in ~a not initialized 'OPTIMIZER-DATA 'OPTIMIZER)) ((SCHEDULER DUM361) (ERROR slot ~a in ~a not initialized 'SCHEDULER 'KERNEL)) ((WORKERS DUM362) (ERROR slot ~a in ~a not initialized 'WORKERS 'KERNEL)) ((WORKERS-LOCK DUM363) (ERROR slot ~a in ~a not initialized 'WORKERS-LOCK 'KERNEL)) ((WORKER-INFO DUM364) (ERROR slot ~a in ~a not initialized 'WORKER-INFO 'KERNEL)) ((ALIVEP DUM365) (ERROR slot ~a in ~a not initialized 'ALIVEP 'KERNEL)))

MAKE-OPTIMIZER-INSTANCE

MAKE-SCHEDULER (WORKERS SPIN-COUNT)

MAKE-SCHEDULER-INSTANCE (&KEY ((WORKERS DUM212) (ERROR slot ~a in ~a not initialized 'WORKERS 'SCHEDULER)) ((WAIT-CVAR DUM213) (MAKE-CONDITION-VARIABLE)) ((WAIT-LOCK DUM214) (MAKE-LOCK)) ((WAIT-COUNT DUM215) (MAKE-COUNTER)) ((NOTIFY-COUNT DUM216) 0) ((SPIN-COUNT DUM217) (ERROR slot ~a in ~a not initialized 'SPIN-COUNT 'SCHEDULER)) ((RANDOM-INDEX DUM218) 0) ((LOW-PRIORITY-TASKS DUM219) (MAKE-SPIN-QUEUE)))

MAKE-TASK

MAKE-TASK-INSTANCE (&KEY (FN (ERROR slot ~a in ~a not initialized 'FN 'TASK)) (CATEGORY (ERROR slot ~a in ~a not initialized 'CATEGORY 'TASK)))

MAKE-TIMEOUT-INSTANCE (&KEY ((CANCELED-RESULT DUM0) (ERROR slot ~a in ~a not initialized 'CANCELED-RESULT 'TIMEOUT)) ((THREAD DUM1) (ERROR slot ~a in ~a not initialized 'THREAD 'TIMEOUT)) ((LOCK DUM2) (MAKE-LOCK)))

MAKE-WORKER (KERNEL INDEX TASKS)

MAKE-WORKER-INFO-INSTANCE (&KEY ((BINDINGS DUM0) (ERROR slot ~a in ~a not initialized 'BINDINGS 'WORKER-INFO)) ((CONTEXT DUM1) (ERROR slot ~a in ~a not initialized 'CONTEXT 'WORKER-INFO)) ((NAME DUM2) (ERROR slot ~a in ~a not initialized 'NAME 'WORKER-INFO)))

MAKE-WORKER-INSTANCE (&KEY ((HANDSHAKE/FROM-WORKER DUM110) (MAKE-QUEUE)) ((HANDSHAKE/TO-WORKER DUM111) (MAKE-QUEUE)) ((EXIT-NOTIFICATION DUM112) (MAKE-QUEUE)) ((THREAD DUM113) (ERROR slot ~a in ~a not initialized 'THREAD 'WORKER)) ((RUNNING-CATEGORY DUM114) NIL) ((INDEX DUM115) (ERROR slot ~a in ~a not initialized 'INDEX 'WORKER)) ((TASKS DUM116) (ERROR slot ~a in ~a not initialized 'TASKS 'WORKER)))

MAKE-WORKER-NOTIFICATIONS-INSTANCE (&KEY ((HANDSHAKE/FROM-WORKER DUM56) (MAKE-QUEUE)) ((HANDSHAKE/TO-WORKER DUM57) (MAKE-QUEUE)) ((EXIT-NOTIFICATION DUM58) (MAKE-QUEUE)))

MAKE-WORKER-THREAD (KERNEL WORKER NAME BINDINGS)

MAKE-WORKERS (KERNEL WORKER-VECTOR)

MAKE-WRAPPED-ERROR-INSTANCE (&KEY ((CONDITION DUM0) (ERROR slot ~a in ~a not initialized 'CONDITION 'WRAPPED-ERROR)))

MAYBE-WAKE-A-WORKER

NEXT-TASK

NOTIFY-EXIT (WORKER)

OPTIMIZER-P (OBJECT)

PUSH-TO-RANDOM-WORKER

REPLACE-WORKER (KERNEL WORKER)

SCHEDULE-TASK

SCHEDULER-P (OBJECT)

SHUTDOWN (CHANNEL KERNEL)

SIMPLE-STYLE-WARNING (MESSAGE &REST ARGS)

STEAL-TASK

STEAL-WORK

SUBMIT-RAW-TASK (TASK KERNEL)

TIMEOUT-P (OBJECT)

TRACK-EXIT

TRANSFER-ERROR-REPORT (STREAM)

TRANSFER-ERROR-RESTART (&OPTIONAL (ERR *DEBUGGER-ERROR*))

WAIT-FOR-WORKER (WORKER)

WORKER-INFO-P (OBJECT)

WORKER-LOOP

WORKER-NOTIFICATIONS-P (OBJECT)

WORKER-P (OBJECT)

WRAPPED-ERROR-P (OBJECT)

MACRO

Public

DO-FAST-RECEIVES ((RESULT CHANNEL COUNT) &BODY BODY)

Receive `count' number of results from `channel', executing `body' each time with the result bound to `result'. `body' should be a trivial operation such as an aref call.

TASK-HANDLER-BIND (CLAUSES &BODY BODY)

Like `handler-bind' but handles conditions signaled inside tasks that were created in `body'.

Private

Undocumented

DEFINE-MOD-INC-DEC (NAME OP OP-RESULT-TYPE)

DEFINE-MOD-INCF-DECF (NAME OP)

DEFINE-WORKER-INFO-READER (NAME SLOT &OPTIONAL (RESULT SLOT))

DO-INDEXES ((VAR SIZE-FORM START FROM-START-P) &BODY BODY)

DO-WORKERS ((WORKER-VAR WORKERS START-INDEX FROM-START-P) &BODY BODY)

MAKE-TASK-FN (&BODY BODY)

MOD-DEC (K N)

MOD-DECF (PLACE N)

MOD-INC (K N)

MOD-INCF (PLACE N)

REPEAT/FIXNUM (COUNT &BODY BODY)

WITH-CHANNEL-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-KERNEL-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-MAKE-WORKERS-HANDLER (WORKER-VECTOR &BODY BODY)

WITH-OPTIMIZER-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-POP-SUCCESS (VAR QUEUE &BODY BODY)

WITH-SCHEDULER-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-TASK-CONTEXT (&BODY BODY)

WITH-TIMEOUT-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-TRACKED-ERROR (CONDITION &BODY BODY)

WITH-WORKER-INFO-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-WORKER-NOTIFICATIONS-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-WORKER-RESTARTS (&BODY BODY)

WITH-WORKER-SLOTS (SLOTS INSTANCE &BODY BODY)

WITH-WRAPPED-ERROR-SLOTS (SLOTS INSTANCE &BODY BODY)

VARIABLE

Public

*DEBUG-TASKS-P*

If true (the default), the debugger is invoked when an error goes unhandled inside a task, i.e. when the handlers established by `task-handler-bind' (if any) do not handle it. If false, unhandled errors from tasks are automatically transferred to their parent thread (and/or any dependent threads) via the `transfer-error' restart. This is for convenience -- sometimes you wish to avoid N debugger popups arising from N errors in N worker threads. For local control over debugger invocation, bind a task handler: (task-handler-bind ((error #'invoke-debugger)) ...) (task-handler-bind ((error #'invoke-transfer-error)) ...)

*KERNEL*

The current kernel, or nil.

*KERNEL-SPIN-COUNT*

Default value of the `spin-count' argument to `make-kernel'.

*TASK-CATEGORY*

See `kill-tasks'. Default value is `:default'.

*TASK-PRIORITY*

When bound to `:low', the kernel schedules submitted tasks at low priority. Default value is `:default'.

Private

*CLIENT-HANDLERS*

Records handlers established with `task-handler-bind' in the calling thread.

*DEBUGGER-ERROR*

Track the error inside the debugger for the `transfer-error' restart.

*ERRORING-WORKERS*

Track debugger popups in order to kill them.

*ERRORING-WORKERS-LOCK*

Lock for *erroring-workers*.

*HANDLER-ACTIVE-P*

Non-nil when handlers have been established via `call-with-task-handler'.

*LISP-EXITING-P*

True if the Lisp process is exiting; for skipping auto-replacement of killed workers during exit.

*MAKE-OPTIMIZER-DATA*

A function that creates the optimizer-data instance.

*WORKER*

The worker instance if inside a worker thread, otherwise nil.

CLASS

Public

CHANNEL

A task is submitted to the kernel using a channel. A channel always points to the same kernel, which is the value of `*kernel*' when the channel is created.

KERNEL

The kernel encompasses the scheduling and execution of parallel tasks using a pool of worker threads. All parallelism in lparallel is done on top of the kernel.

Private

OPTIMIZER

Optimization data to be used by a plugin. The `optimizer-flag' flag must be inlined in order to be useful, which is why `kernel' subclasses directly from this.

SCHEDULER (INSTANCE)

A scheduler is responsible for storing tasks and finding the next task to execute. A task may also be stolen from the scheduler. `workers' -- vector of workers; kernel has the same reference. `wait-cvar', `wait-lock', `wait-count', `notify-count' -- these coordinate waking/sleeping of workers. `spin-count' -- see `make-kernel'. `random-index' -- some random index to the vector of workers. `low-priority-tasks' -- tasks submitted when `*task-priority*' is `:low'.

WORKER

A worker represents a thread dedicated to executing tasks. See `kill-tasks' for an explanation of `running-category'. `index' is the location of the worker in the kernel's vector of workers. When the stealing scheduler is enabled, each worker has its own lockless task queue.

WORKER-INFO

Information common to all workers. See `make-kernel'.

WORKER-NOTIFICATIONS

Communication with workers. A handshake takes place when a worker is created in order to verify its existence and to ensure all data is initialized. A worker sends a notification just before it exits.

WRAPPED-ERROR

This is a container for transferring an error that occurs inside `call-with-task-handler' to the calling thread.

Undocumented

TIMEOUT

CONDITION

Public

KERNEL-CREATION-ERROR

Error signaled when `make-kernel' fails.

NO-KERNEL-ERROR

Error signaled when `*kernel*' is nil.

TASK-KILLED-ERROR

Error signaled when attempting to obtain the result of a killed task.

Private

Undocumented

SIMPLE-STYLE-WARNING (MESSAGE &REST ARGS)

CONSTANT

Private

Undocumented

+CURRENT-TASK+

+WORKER-SUICIDE-TAG+