25#include <dbus/dbus-resources.h>
26#include <dbus/dbus-internals.h>
61#ifdef DBUS_ENABLE_STATS
63 long peak_unix_fd_value;
145 last_ref = (counter->
refcount == 0);
178#ifdef DBUS_ENABLE_STATS
179 if (counter->peak_size_value < counter->
size_value)
180 counter->peak_size_value = counter->
size_value;
184 _dbus_verbose (
"Adjusting counter %ld by %ld = %ld\n",
189 ((old < counter->notify_size_guard_value &&
209 DBusCounterNotifyFunction notify_function =
NULL;
210 void *notify_data =
NULL;
221 if (notify_function !=
NULL)
222 (* notify_function) (counter, notify_data);
247#ifdef DBUS_ENABLE_STATS
253 _dbus_verbose (
"Adjusting counter %ld by %ld = %ld\n",
258 ((old < counter->notify_unix_fd_guard_value &&
312 long size_guard_value,
313 long unix_fd_guard_value,
314 DBusCounterNotifyFunction function,
326#ifdef DBUS_ENABLE_STATS
328_dbus_counter_get_peak_size_value (
DBusCounter *counter)
330 return counter->peak_size_value;
334_dbus_counter_get_peak_unix_fd_value (
DBusCounter *counter)
336 return counter->peak_unix_fd_value;
#define _dbus_assert(condition)
Aborts with an error message if the condition is false.
#define NULL
A null pointer, defined appropriately for C or C++.
#define TRUE
Expands to "1".
#define FALSE
Expands to "0".
void dbus_free(void *memory)
Frees a block of memory previously allocated by dbus_malloc() or dbus_malloc0().
#define dbus_new0(type, count)
Safe macro for using dbus_malloc0().
void _dbus_counter_set_notify(DBusCounter *counter, long size_guard_value, long unix_fd_guard_value, DBusCounterNotifyFunction function, void *user_data)
Sets the notify function for this counter; the notify function is called whenever the counter's value...
DBusCounter * _dbus_counter_new(void)
Creates a new DBusCounter.
long _dbus_counter_get_unix_fd_value(DBusCounter *counter)
Gets the current value of the unix fd counter.
void _dbus_counter_unref(DBusCounter *counter)
Decrements refcount of the counter and possibly finalizes the counter.
long _dbus_counter_get_size_value(DBusCounter *counter)
Gets the current value of the size counter.
void _dbus_counter_adjust_unix_fd(DBusCounter *counter, long delta)
Adjusts the value of the unix fd counter by the given delta which may be positive or negative.
void _dbus_counter_notify(DBusCounter *counter)
Calls the notify function from _dbus_counter_set_notify(), if that function has been specified and th...
DBusCounter * _dbus_counter_ref(DBusCounter *counter)
Increments refcount of the counter.
void _dbus_counter_adjust_size(DBusCounter *counter, long delta)
Adjusts the value of the size counter by the given delta which may be positive or negative.
void _dbus_rmutex_new_at_location(DBusRMutex **location_p)
Creates a new mutex or creates a no-op mutex if threads are not initialized.
DBUS_PRIVATE_EXPORT void _dbus_rmutex_unlock(DBusRMutex *mutex)
Unlocks a mutex.
void _dbus_rmutex_free_at_location(DBusRMutex **location_p)
Frees a DBusRMutex; does nothing if passed a NULL pointer.
DBUS_PRIVATE_EXPORT void _dbus_rmutex_lock(DBusRMutex *mutex)
Locks a mutex.
dbus_uint32_t dbus_bool_t
A boolean, valid values are TRUE and FALSE.
Internals of DBusCounter.
int refcount
reference count
void * notify_data
data for notify function
DBusCounterNotifyFunction notify_function
notify function
long notify_unix_fd_guard_value
call notify function when crossing this unix fd value
dbus_bool_t notify_pending
TRUE if the guard value has been crossed.
long size_value
current size counter value
DBusRMutex * mutex
Lock on the entire DBusCounter.
long unix_fd_value
current unix fd counter value
long notify_size_guard_value
call notify function when crossing this size value