counter.h File Reference

The isc_counter_t object is a simplified version of the isc_quota_t object; it tracks the consumption of limited resources, returning an error condition when the quota is exceeded. However, unlike isc_quota_t, attaching and detaching from a counter object does not increment or decrement the counter. More...

#include <isc/lang.h>
#include <isc/mutex.h>
#include <isc/types.h>

Go to the source code of this file.

Defines

#define ISC_COUNTER_H   1

Functions

ISC_LANG_BEGINDECLS isc_result_t isc_counter_create (isc_mem_t *mctx, int limit, isc_counter_t **counterp)
 Allocate and initialize a counter object.
isc_result_t isc_counter_increment (isc_counter_t *counter)
 Increment the counter.
unsigned int isc_counter_used (isc_counter_t *counter)
 Return the current counter value.
void isc_counter_setlimit (isc_counter_t *counter, int limit)
 Set the counter limit.
void isc_counter_attach (isc_counter_t *source, isc_counter_t **targetp)
 Attach to a counter object, increasing its reference counter.
void isc_counter_detach (isc_counter_t **counterp)
 Detach (and destroy if reference counter has dropped to zero) a counter object.


Detailed Description

The isc_counter_t object is a simplified version of the isc_quota_t object; it tracks the consumption of limited resources, returning an error condition when the quota is exceeded. However, unlike isc_quota_t, attaching and detaching from a counter object does not increment or decrement the counter.

Definition in file counter.h.


Define Documentation

#define ISC_COUNTER_H   1

Definition at line 18 of file counter.h.


Function Documentation

ISC_LANG_BEGINDECLS isc_result_t isc_counter_create ( isc_mem_t mctx,
int  limit,
isc_counter_t **  counterp 
)

Allocate and initialize a counter object.

Definition at line 41 of file counter.c.

References counter, COUNTER_MAGIC, isc_mem_attach(), isc_mem_get, isc_mem_put, isc_mutex_init, ISC_R_NOMEMORY, ISC_R_SUCCESS, isc_counter::limit, isc_counter::lock, isc_counter::magic, isc_counter::mctx, isc_counter::references, REQUIRE, and isc_counter::used.

Referenced by ATF_TC_BODY(), and fctx_create().

isc_result_t isc_counter_increment ( isc_counter_t counter  ) 

Increment the counter.

If the counter limit is nonzero and has been reached, then return ISC_R_QUOTA, otherwise ISC_R_SUCCESS. (The counter is incremented regardless of return value.)

Definition at line 70 of file counter.c.

References ISC_R_QUOTA, ISC_R_SUCCESS, isc_counter::limit, isc_counter::lock, LOCK, UNLOCK, and isc_counter::used.

Referenced by ATF_TC_BODY(), and fctx_try().

unsigned int isc_counter_used ( isc_counter_t counter  ) 

Return the current counter value.

Definition at line 83 of file counter.c.

References REQUIRE, isc_counter::used, and VALID_COUNTER.

Referenced by ATF_TC_BODY(), and fctx_try().

void isc_counter_setlimit ( isc_counter_t counter,
int  limit 
)

Set the counter limit.

Definition at line 90 of file counter.c.

References isc_counter::limit, isc_counter::lock, LOCK, REQUIRE, UNLOCK, and VALID_COUNTER.

Referenced by ATF_TC_BODY().

void isc_counter_attach ( isc_counter_t source,
isc_counter_t **  targetp 
)

Attach to a counter object, increasing its reference counter.

Definition at line 99 of file counter.c.

References INSIST, isc_counter::lock, LOCK, isc_counter::references, REQUIRE, UNLOCK, and VALID_COUNTER.

Referenced by fctx_create().

void isc_counter_detach ( isc_counter_t **  counterp  ) 

Detach (and destroy if reference counter has dropped to zero) a counter object.

Definition at line 119 of file counter.c.

References counter, destroy(), INSIST, ISC_FALSE, ISC_TRUE, isc_counter::lock, LOCK, isc_counter::references, REQUIRE, UNLOCK, and VALID_COUNTER.

Referenced by ATF_TC_BODY(), fctx_create(), and fctx_destroy().


Generated on Tue Apr 28 17:41:15 2015 by Doxygen 1.5.4 for BIND9 Internals 9.11.0pre-alpha