27#include <dbus/dbus-resources.h>
28#include <dbus/dbus-internals.h>
63#ifdef DBUS_ENABLE_STATS
65 long peak_unix_fd_value;
140 dbus_bool_t last_ref =
FALSE;
147 last_ref = (counter->
refcount == 0);
180#ifdef DBUS_ENABLE_STATS
181 if (counter->peak_size_value < counter->
size_value)
182 counter->peak_size_value = counter->
size_value;
186 _dbus_verbose (
"Adjusting counter %ld by %ld = %ld\n",
191 ((old < counter->notify_size_guard_value &&
211 DBusCounterNotifyFunction notify_function =
NULL;
212 void *notify_data =
NULL;
223 if (notify_function !=
NULL)
224 (* notify_function) (counter, notify_data);
249#ifdef DBUS_ENABLE_STATS
255 _dbus_verbose (
"Adjusting counter %ld by %ld = %ld\n",
260 ((old < counter->notify_unix_fd_guard_value &&
314 long size_guard_value,
315 long unix_fd_guard_value,
316 DBusCounterNotifyFunction function,
328#ifdef DBUS_ENABLE_STATS
330_dbus_counter_get_peak_size_value (
DBusCounter *counter)
332 return counter->peak_size_value;
336_dbus_counter_get_peak_unix_fd_value (
DBusCounter *counter)
338 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.
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