4 * The contents of this file are subject to the terms of the
5 * Common Development and Distribution License, Version 1.0 only
6 * (the "License"). You may not use this file except in compliance
9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
10 * or http://www.opensolaris.org/os/licensing.
11 * See the License for the specific language governing permissions
12 * and limitations under the License.
14 * When distributing Covered Code, include this CDDL HEADER in each
15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
16 * If applicable, add the following below this CDDL HEADER, with the
17 * fields enclosed by brackets "[]" replaced with your own identifying
18 * information: Portions Copyright [yyyy] [name of copyright owner]
23 * Copyright 2004 Sun Microsystems, Inc. All rights reserved.
24 * Use is subject to license terms.
30 #pragma ident "%Z%%M% %I% %E% SMI"
39 #include <fmd_idspace.h>
40 #include <fmd_thread.h>
41 #include <fmd_event.h>
44 typedef void fmd_timer_f(void *, id_t
, hrtime_t
);
46 typedef struct fmd_timer
{
47 fmd_list_t tmr_list
; /* expiry or free list next/prev pointers */
48 hrtime_t tmr_hrt
; /* high-res time at which timer should fire */
49 fmd_idspace_t
*tmr_ids
; /* idspace that contains the timer id */
50 id_t tmr_id
; /* client identifier for this timer */
51 fmd_timer_f
*tmr_func
; /* function that should be called on expiry */
52 void *tmr_arg
; /* argument to pass back to tmr_func */
53 pthread_cond_t tmr_cv
; /* condition variable for waiting on tmr_func */
56 typedef struct fmd_timerq
{
57 fmd_thread_t
*tmq_thread
; /* thread handling timer expiry for queue */
58 uint_t tmq_abort
; /* flag indicating tmq_thread should abort */
59 pthread_mutex_t tmq_lock
; /* lock protecting timer queue contents */
60 pthread_cond_t tmq_cv
; /* condition variable for tmq_list, abort */
61 fmd_list_t tmq_list
; /* list of active timers, sorted by tmr_hrt */
62 fmd_list_t tmq_free
; /* list of free timers */
65 extern id_t
fmd_timerq_install(fmd_timerq_t
*,
66 fmd_idspace_t
*, fmd_timer_f
*, void *, fmd_event_t
*, hrtime_t
);
68 extern void *fmd_timerq_remove(fmd_timerq_t
*, fmd_idspace_t
*, id_t
);
69 extern fmd_timerq_t
*fmd_timerq_create(void);
70 extern void fmd_timerq_destroy(fmd_timerq_t
*);
76 #endif /* _FMD_TIMERQ_H */