1124882Srwatson/*- 2124882Srwatson * Copyright (c) 2000 Doug Rabson 3124882Srwatson * All rights reserved. 4124882Srwatson * 5124882Srwatson * Redistribution and use in source and binary forms, with or without 6124882Srwatson * modification, are permitted provided that the following conditions 7124882Srwatson * are met: 8124882Srwatson * 1. Redistributions of source code must retain the above copyright 9124882Srwatson * notice, this list of conditions and the following disclaimer. 10124882Srwatson * 2. Redistributions in binary form must reproduce the above copyright 11124882Srwatson * notice, this list of conditions and the following disclaimer in the 12124882Srwatson * documentation and/or other materials provided with the distribution. 13124882Srwatson * 14124882Srwatson * THIS SOFTWARE IS PROVIDED BY THE AUTHOR AND CONTRIBUTORS ``AS IS'' AND 15124882Srwatson * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 16124882Srwatson * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 17124882Srwatson * ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR OR CONTRIBUTORS BE LIABLE 18124882Srwatson * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 19124882Srwatson * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 20124882Srwatson * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 21124882Srwatson * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 22124882Srwatson * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 23124882Srwatson * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 24124882Srwatson * SUCH DAMAGE. 25124882Srwatson * 26124882Srwatson * $FreeBSD$ 27124882Srwatson */ 28124882Srwatson 29124882Srwatson#ifndef _SYS__TASK_H_ 30124882Srwatson#define _SYS__TASK_H_ 31124882Srwatson 32124882Srwatson#include <sys/queue.h> 33124882Srwatson 34124882Srwatson/* 35124882Srwatson * Each task includes a function which is called from 36124882Srwatson * taskqueue_run(). The first argument is taken from the 'ta_context' 37124882Srwatson * field of struct task and the second argument is a count of how many 38124882Srwatson * times the task was enqueued before the call to taskqueue_run(). 39210377Smdf * 40210377Smdf * List of locks 41210377Smdf * (c) const after init 42210377Smdf * (q) taskqueue lock 43124882Srwatson */ 44124882Srwatsontypedef void task_fn_t(void *context, int pending); 45124882Srwatson 46124882Srwatsonstruct task { 47210377Smdf STAILQ_ENTRY(task) ta_link; /* (q) link for queue */ 48210377Smdf u_short ta_pending; /* (q) count times queued */ 49210377Smdf u_short ta_priority; /* (c) Priority */ 50210377Smdf task_fn_t *ta_func; /* (c) task handler */ 51210377Smdf void *ta_context; /* (c) argument for handler */ 52124882Srwatson}; 53124882Srwatson 54124882Srwatson#endif /* !_SYS__TASK_H_ */ 55