Lines Matching refs:counter

58   long size_value;       /**< current size counter value */
59 long unix_fd_value; /**< current unix fd counter value */
79 * @returns new counter or #NULL on failure
84 DBusCounter *counter;
86 counter = dbus_new (DBusCounter, 1);
87 if (counter == NULL)
90 counter->refcount = 1;
91 counter->size_value = 0;
92 counter->unix_fd_value = 0;
94 counter->notify_size_guard_value = 0;
95 counter->notify_unix_fd_guard_value = 0;
96 counter->notify_function = NULL;
97 counter->notify_data = NULL;
99 return counter;
103 * Increments refcount of the counter
105 * @param counter the counter
106 * @returns the counter
109 _dbus_counter_ref (DBusCounter *counter)
111 _dbus_assert (counter->refcount > 0);
113 counter->refcount += 1;
115 return counter;
119 * Decrements refcount of the counter and possibly
120 * finalizes the counter.
122 * @param counter the counter
125 _dbus_counter_unref (DBusCounter *counter)
127 _dbus_assert (counter->refcount > 0);
129 counter->refcount -= 1;
131 if (counter->refcount == 0)
134 dbus_free (counter);
139 * Adjusts the value of the size counter by the given
144 * @param counter the counter
145 * @param delta value to add to the size counter's current value
148 _dbus_counter_adjust_size (DBusCounter *counter,
151 long old = counter->size_value;
153 counter->size_value += delta;
156 _dbus_verbose ("Adjusting counter %ld by %ld = %ld\n",
157 old, delta, counter->size_value);
160 if (counter->notify_function != NULL &&
161 ((old < counter->notify_size_guard_value &&
162 counter->size_value >= counter->notify_size_guard_value) ||
163 (old >= counter->notify_size_guard_value &&
164 counter->size_value < counter->notify_size_guard_value)))
165 (* counter->notify_function) (counter, counter->notify_data);
169 * Adjusts the value of the unix fd counter by the given
174 * @param counter the counter
175 * @param delta value to add to the unix fds counter's current value
178 _dbus_counter_adjust_unix_fd (DBusCounter *counter,
181 long old = counter->unix_fd_value;
183 counter->unix_fd_value += delta;
186 _dbus_verbose ("Adjusting counter %ld by %ld = %ld\n",
187 old, delta, counter->unix_fd_value);
190 if (counter->notify_function != NULL &&
191 ((old < counter->notify_unix_fd_guard_value &&
192 counter->unix_fd_value >= counter->notify_unix_fd_guard_value) ||
193 (old >= counter->notify_unix_fd_guard_value &&
194 counter->unix_fd_value < counter->notify_unix_fd_guard_value)))
195 (* counter->notify_function) (counter, counter->notify_data);
199 * Gets the current value of the size counter.
201 * @param counter the counter
205 _dbus_counter_get_size_value (DBusCounter *counter)
207 return counter->size_value;
211 * Gets the current value of the unix fd counter.
213 * @param counter the counter
217 _dbus_counter_get_unix_fd_value (DBusCounter *counter)
219 return counter->unix_fd_value;
223 * Sets the notify function for this counter; the notify function is
224 * called whenever the counter's values cross the guard values in
227 * @param counter the counter
228 * @param size_guard_value the value we're notified if the size counter crosses
229 * @param unix_fd_guard_value the value we're notified if the unix fd counter crosses
234 _dbus_counter_set_notify (DBusCounter *counter,
240 counter->notify_size_guard_value = size_guard_value;
241 counter->notify_unix_fd_guard_value = unix_fd_guard_value;
242 counter->notify_function = function;
243 counter->notify_data = user_data;