chickadee » wodehaus » start

start producer #!optional consumer logger fixnumprocedure

Starts a job server.

When started, the server loops indefinitely, calling producer to generate workers and jobs to be dispatched. If there are no jobs to run, it is the producer's responsibility to block until one becomes available. To stop the server, producer should raise the #:stop keyword.

The final argument to start sets the maximum number of concurrent workers the job server will use. The default value is 4.

Each worker is executed in a dedicated OS-level process. A worker receives as a single argument the job with which it was produced, and its result is passed back to the consumer in the server process. Worker arguments and results must be fully read/write-invariant.

The consumer procedure is invoked with each completed job and its result. Its own result is discarded.

Each job server uses its thread's "specific" data slot for bookkeeping and installs a SIGINT handler that will cause the server to shut down cleanly on interrupt. It's recommended that each job server be run in a dedicated thread.