14.20. Slapi_Counter
Slapi_Counter allows plug-ins to use global integers that can be updated by multiple worker threads in a thread-safe manner.
Slapi_Counter structure is a wrapper around the actual counter value.
#include "slapi-plugin.h"
typedef struct Slapi_Counter {
PRUint64 value;
#ifndef ATOMIC_64BIT_OPERATIONS
Slapi_Mutex *mutex;
#endif
} Slapi_Counter;
Slapi_Counter defines settings for counters. The different functions available to Slapi_Counter structures are listed in Table 14.13, “Functions for Slapi_Counter”.
Table 14.13. Functions for Slapi_Counter
| To ... | ... Call this function |
|---|---|
| Create a new counter. | slapi_counter_new() |
| Initialize a new counter. | slapi_counter_init() |
| Increment the counter value and return the new value. | slapi_counter_increment() |
| Decrement the counter and return the new value. | slapi_counter_decrement() |
| Add a certain amount to the counter value. | slapi_counter_add() |
| Subtract a certain amount from the counter value. | slapi_counter_subtract() |
| Set the counter to a new, specified value and returns the updated value. | slapi_counter_set_value() |
| Get the current value of the counter. | slapi_counter_get_value() |
| Destroy an existing counter. | slapi_counter_destroy() |

Where did the comment section go?
Red Hat's documentation publication system recently went through an upgrade to enable speedier, more mobile-friendly content. We decided to re-evaluate our commenting platform to ensure that it meets your expectations and serves as an optimal feedback mechanism. During this redesign, we invite your input on providing feedback on Red Hat documentation via the discussion platform.