thq.h revision 7c478bd95313f5f23a4c958a745db2134aa03244
/*
* CDDL HEADER START
*
* The contents of this file are subject to the terms of the
* Common Development and Distribution License, Version 1.0 only
* (the "License"). You may not use this file except in compliance
* with the License.
*
* You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
* See the License for the specific language governing permissions
* and limitations under the License.
*
* When distributing Covered Code, include this CDDL HEADER in each
* file and include the License file at usr/src/OPENSOLARIS.LICENSE.
* If applicable, add the following below this CDDL HEADER, with the
* fields enclosed by brackets "[]" replaced with your own identifying
* information: Portions Copyright [yyyy] [name of copyright owner]
*
* CDDL HEADER END
*/
/*
* Copyright (c) 1999-2001 by Sun Microsystems, Inc.
* All rights reserved.
*/
#ifndef _THQ_H
#define _THQ_H
#pragma ident "%Z%%M% %I% %E% SMI"
/*
* This file contains the definitions for the thread
* management module (thq.h).
*/
#ifdef __cplusplus
extern "C" {
#endif
#include <pthread.h>
typedef void * (*PFP)(void *);
typedef void * (*PFP2)(void *, void *);
typedef struct tq_listS {
void * arg;
typedef struct {
int *shutdown; /* variable to test for shutdown condition */
int shutalloc; /* was shutdown variable allocated locally */
int stopping; /* queue is currently stopping */
int queue_size; /* current size of the queue */
int nb_thr; /* current nb of threads pocessing the queue */
int thr_waiting; /* current nb of threads waiting */
int max_thr; /* max allowed threads to process the queue */
int min_thr; /* min nb of threads to keep alive */
int wd_mask; /* Watchdog mask */
PFP2, /* function called before to end */
void *, /* arg passed to both functions */
int *, /* shutdown variable to test */
int, /* max allowed threads */
int, /* min allowed threads */
boolean_t); /* If TRUE all inactive threads are killed */
void *); /* element to be queued */
/*
* tq_dequeue returns the first "arg" passed to tq_queue
*/
void *); /* pointer to "shutdown" arguments */
/*
* tq_shutdown, shutdown the queue (alternate way to shutdown if you don't
* have a global shutdown integer
*
* shutdown can be immediate (1) or delayed until there is nothing more
* in the queue (immediate = 0)
*
* when you call this function, no more argument can be queued using
* tq_queue.
*
* when tq_dequeue returns, the queue pointer is not allocated anymore
*
*/
int); /* 1: don't wait, 0: wait for queue */
/* to be empty */
#ifdef __cplusplus
}
#endif
#endif /* _THQ_H */