quota.h revision 0c27b3fe77ac1d5094ba3521e8142d9e7973133f
/*
* Copyright (C) 2000, 2001, 2004, 2005, 2007, 2016 Internet Systems Consortium, Inc. ("ISC")
*
* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/.
*/
/* $Id: quota.h,v 1.16 2007/06/19 23:47:18 tbox Exp $ */
#ifndef ISC_QUOTA_H
#define ISC_QUOTA_H 1
/*****
***** Module Info
*****/
*
* \brief The isc_quota_t object is a simple helper object for implementing
* quotas on things like the number of simultaneous connections to
* a server. It keeps track of the amount of quota in use, and
* encapsulates the locking necessary to allow multiple tasks to
* share a quota.
*/
/***
*** Imports.
***/
/*****
***** Types.
*****/
/*% isc_quota structure */
struct isc_quota {
int max;
int used;
int soft;
};
/*%<
* Initialize a quota object.
*
* Returns:
* ISC_R_SUCCESS
* Other error Lock creation failed.
*/
void
/*%<
* Destroy a quota object.
*/
void
/*%<
* Set a soft quota.
*/
void
/*%<
* Re-set a maximum quota.
*/
/*%<
* Attempt to reserve one unit of 'quota'.
*
* Returns:
* \li #ISC_R_SUCCESS Success
* \li #ISC_R_SOFTQUOTA Success soft quota reached
* \li #ISC_R_QUOTA Quota is full
*/
void
/*%<
* Release one unit of quota.
*/
/*%<
* Like isc_quota_reserve, and also attaches '*p' to the
* quota if successful (ISC_R_SUCCESS or ISC_R_SOFTQUOTA).
*/
void
isc_quota_detach(isc_quota_t **p);
/*%<
* Like isc_quota_release, and also detaches '*p' from the
* quota.
*/
#endif /* ISC_QUOTA_H */