task.c revision bae70907555b89759d803402111b06a2aefd1b67
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * Copyright (C) 1998, 1999 Internet Software Consortium.
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * Permission to use, copy, modify, and distribute this software for any
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * purpose with or without fee is hereby granted, provided that the above
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * copyright notice and this permission notice appear in all copies.
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * THE SOFTWARE IS PROVIDED "AS IS" AND INTERNET SOFTWARE CONSORTIUM DISCLAIMS
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL INTERNET SOFTWARE
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * CONSORTIUM BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews * ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS
393fd55d91306e6def3a3d06748eee031f57bd17Mark Andrews#define XTRACE(m) printf("%s task %p thread %lu\n", (m), \
} task_state_t;
struct isc_task {
unsigned int magic;
unsigned int references;
unsigned int quantum;
struct isc_taskmgr {
unsigned int magic;
unsigned int workers;
unsigned int default_quantum;
static inline isc_event_t *
return (NULL);
return (event);
return (NULL);
if (type < 0)
return (NULL);
return (NULL);
return (ISC_R_NOMEMORY);
return (ISC_R_UNEXPECTED);
return (ISC_R_SUCCESS);
if (free_task)
if (disallowed)
return (result);
if (was_idle) {
return (ISC_R_SUCCESS);
unsigned int purge_count;
purge_count = 0;
purge_count++;
return (purge_count);
return (result);
NULL,
arg,
sizeof *event);
return (ISC_R_NOMEMORY);
if (disallowed)
return (result);
static isc_threadresult_t
#ifdef _WIN32
unsigned int dispatch_count = 0;
while (!done) {
if (free_task)
if (requeue) {
return ((isc_threadresult_t)0);
unsigned int i, started = 0;
return (ISC_R_NOMEMORY);
return (ISC_R_NOMEMORY);
return (ISC_R_UNEXPECTED);
if (default_quantum == 0)
return (ISC_R_UNEXPECTED);
for (i = 0; i < workers; i++) {
started++;
if (started == 0) {
return (ISC_R_NOTHREADS);
return (ISC_R_SUCCESS);