Add BIND 9.2.4rc7.
[dragonfly.git] / contrib / bind-9.2.4rc7 / lib / isc / include / isc / quota.h
blobdf885d85c9add943d0dfa3c05a7798107f9ba0d0
1 /*
2 * Copyright (C) 2004 Internet Systems Consortium, Inc. ("ISC")
3 * Copyright (C) 2000, 2001 Internet Software Consortium.
5 * Permission to use, copy, modify, and distribute this software for any
6 * purpose with or without fee is hereby granted, provided that the above
7 * copyright notice and this permission notice appear in all copies.
9 * THE SOFTWARE IS PROVIDED "AS IS" AND ISC DISCLAIMS ALL WARRANTIES WITH
10 * REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
11 * AND FITNESS. IN NO EVENT SHALL ISC BE LIABLE FOR ANY SPECIAL, DIRECT,
12 * INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
13 * LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE
14 * OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
15 * PERFORMANCE OF THIS SOFTWARE.
18 /* $Id: quota.h,v 1.8.2.1 2004/03/09 06:11:59 marka Exp $ */
20 #ifndef ISC_QUOTA_H
21 #define ISC_QUOTA_H 1
23 /*****
24 ***** Module Info
25 *****/
28 * Quota
30 * The isc_quota_t object is a simple helper object for implementing
31 * quotas on things like the number of simultaneous connections to
32 * a server. It keeps track of the amount of quota in use, and
33 * encapsulates the locking necessary to allow multiple tasks to
34 * share a quota.
37 /***
38 *** Imports.
39 ***/
41 #include <isc/lang.h>
42 #include <isc/mutex.h>
43 #include <isc/types.h>
45 /*****
46 ***** Types.
47 *****/
49 ISC_LANG_BEGINDECLS
51 struct isc_quota {
52 isc_mutex_t lock;
53 /* Locked by lock. */
54 int max;
55 int used;
58 isc_result_t
59 isc_quota_init(isc_quota_t *quota, int max);
61 * Initialize a quota object.
63 * Returns:
64 * ISC_R_SUCCESS
65 * Other error Lock creation failed.
68 void
69 isc_quota_destroy(isc_quota_t *quota);
71 * Destroy a quota object.
74 isc_result_t
75 isc_quota_reserve(isc_quota_t *quota);
77 * Attempt to reserve one unit of 'quota'.
79 * Returns:
80 * ISC_R_SUCCESS Success
81 * ISC_R_QUOTA Quota is full
84 void
85 isc_quota_release(isc_quota_t *quota);
87 * Release one unit of quota.
90 isc_result_t
91 isc_quota_attach(isc_quota_t *quota, isc_quota_t **p);
93 * Like isc_quota_reserve, and also attaches '*p' to the
94 * quota if successful.
97 void
98 isc_quota_detach(isc_quota_t **p);
100 * Like isc_quota_release, and also detaches '*p' from the
101 * quota.
104 ISC_LANG_ENDDECLS
106 #endif /* ISC_QUOTA_H */