NAME
Worker, getworker, workerdebug – auxiliary worker threads

SYNOPSIS
#include <u.h>
#include <libc.h>
#include <thread.h>
#include <worker.h>

typedef char* (*Worker)(void *arg, void **aux);
int    getworker(Worker work, void *arg, Channel *rc);
void workerdebug(int); extern int (*workerthreadcreate)(void(*)(void*), void*, uint);

DESCRIPTION
This library provices a pool of worker threads to handle user requests. Worker threads are created on demand and never destroyed. Idle workers are kept around waiting for more busy times.

Getworker allocates a new worker to perform work on the given arg , as supplied by the caller. If rc is non null, the result value of work is sent through it upon completion.

The argument aux given to work points to a per–worker storage area that may hold a single pointer. This is useful, for example, to keep reply channels cached.

The global workerthreadcreate is used to create new worker thread. By default, it is initialized to threadcreate (2). Initialize with the address of proccreate to create worker processes instead of threads. The stack size is mainstacksize .

SOURCE
/sys/src/libworker

BUGS
This is a new library and is expected to evolve.
Copyright © 2024 Plan 9 Foundation. All rights reserved.