Lines Matching defs:pending

2 /* dbus-pending-call.c Object representing a call in progress.
27 #include "dbus-pending-call-internal.h"
28 #include "dbus-pending-call.h"
84 * Creates a new pending reply object.
88 * @param timeout_handler timeout handler, takes pending call as data
96 DBusPendingCall *pending;
107 pending = dbus_new0 (DBusPendingCall, 1);
109 if (pending == NULL)
119 pending, NULL);
124 dbus_free (pending);
128 pending->timeout = timeout;
132 pending->timeout = NULL;
135 _dbus_atomic_inc (&pending->refcount);
136 pending->connection = connection;
137 _dbus_connection_ref_unlocked (pending->connection);
139 _dbus_data_slot_list_init (&pending->slot_list);
141 return pending;
145 * Sets the reply of a pending call with the given message,
146 * or if the message is #NULL, by timing out the pending call.
148 * @param pending the pending call
153 _dbus_pending_call_set_reply_unlocked (DBusPendingCall *pending,
158 message = pending->timeout_link->data;
159 _dbus_list_clear (&pending->timeout_link);
164 _dbus_verbose (" handing message %p (%s) to pending call serial %u\n",
170 pending->reply_serial);
172 _dbus_assert (pending->reply == NULL);
173 _dbus_assert (pending->reply_serial == dbus_message_get_reply_serial (message));
174 pending->reply = message;
178 * Calls notifier function for the pending call
181 * @param pending the pending call
185 _dbus_pending_call_complete (DBusPendingCall *pending)
187 _dbus_assert (!pending->completed);
189 pending->completed = TRUE;
191 if (pending->function)
194 user_data = dbus_pending_call_get_data (pending,
197 (* pending->function) (pending, user_data);
202 * If the pending call hasn't been timed out, add its timeout
205 * @param pending the pending call
209 _dbus_pending_call_queue_timeout_error_unlocked (DBusPendingCall *pending,
212 _dbus_assert (connection == pending->connection);
214 if (pending->timeout_link)
217 pending->timeout_link);
218 pending->timeout_link = NULL;
225 * @param pending the pending_call
229 _dbus_pending_call_is_timeout_added_unlocked (DBusPendingCall *pending)
231 _dbus_assert (pending != NULL);
233 return pending->timeout_added;
240 * @param pending the pending_call
244 _dbus_pending_call_set_timeout_added_unlocked (DBusPendingCall *pending,
247 _dbus_assert (pending != NULL);
249 pending->timeout_added = is_added;
256 * @param pending the pending_call
260 _dbus_pending_call_get_timeout_unlocked (DBusPendingCall *pending)
262 _dbus_assert (pending != NULL);
264 return pending->timeout;
270 * @param pending the pending_call
274 _dbus_pending_call_get_reply_serial_unlocked (DBusPendingCall *pending)
276 _dbus_assert (pending != NULL);
278 return pending->reply_serial;
284 * @param pending the pending_call
288 _dbus_pending_call_set_reply_serial_unlocked (DBusPendingCall *pending,
291 _dbus_assert (pending != NULL);
292 _dbus_assert (pending->reply_serial == 0);
294 pending->reply_serial = serial;
298 * Gets the connection associated with this pending call.
300 * @param pending the pending_call
301 * @returns the connection associated with the pending call
304 _dbus_pending_call_get_connection_and_lock (DBusPendingCall *pending)
306 _dbus_assert (pending != NULL);
308 CONNECTION_LOCK (pending->connection);
309 return pending->connection;
313 * Gets the connection associated with this pending call.
315 * @param pending the pending_call
316 * @returns the connection associated with the pending call
319 _dbus_pending_call_get_connection_unlocked (DBusPendingCall *pending)
321 _dbus_assert (pending != NULL);
323 return pending->connection;
327 * Sets the reply message associated with the pending call to a timeout error
329 * @param pending the pending_call
335 _dbus_pending_call_set_timeout_error_unlocked (DBusPendingCall *pending,
358 pending->timeout_link = reply_link;
360 _dbus_pending_call_set_reply_serial_unlocked (pending, serial);
366 * Increments the reference count on a pending call,
369 * @param pending the pending call object
370 * @returns the pending call object
373 _dbus_pending_call_ref_unlocked (DBusPendingCall *pending)
375 _dbus_atomic_inc (&pending->refcount);
377 return pending;
382 _dbus_pending_call_last_unref (DBusPendingCall *pending)
389 _dbus_assert (!pending->timeout_added);
391 connection = pending->connection;
394 _dbus_data_slot_list_free (&pending->slot_list);
396 if (pending->timeout != NULL)
397 _dbus_timeout_unref (pending->timeout);
399 if (pending->timeout_link)
401 dbus_message_unref ((DBusMessage *)pending->timeout_link->data);
402 _dbus_list_free_link (pending->timeout_link);
403 pending->timeout_link = NULL;
406 if (pending->reply)
408 dbus_message_unref (pending->reply);
409 pending->reply = NULL;
412 dbus_free (pending);
418 * calling out to application code where the pending exists
425 * Decrements the reference count on a pending call,
429 * @param pending the pending call object
432 _dbus_pending_call_unref_and_unlock (DBusPendingCall *pending)
436 old_refcount = _dbus_atomic_dec (&pending->refcount);
439 CONNECTION_UNLOCK (pending->connection);
442 _dbus_pending_call_last_unref (pending);
446 * Checks whether the pending call has received a reply
449 * @param pending the pending call
453 _dbus_pending_call_get_completed_unlocked (DBusPendingCall *pending)
455 return pending->completed;
465 * the pending call is finalized. The slot number
468 * @param pending the pending_call
475 _dbus_pending_call_set_data_unlocked (DBusPendingCall *pending,
485 &pending->slot_list,
490 CONNECTION_UNLOCK (pending->connection);
498 CONNECTION_LOCK (pending->connection);
520 * Opaque data type representing a message pending.
524 * Increments the reference count on a pending call.
526 * @param pending the pending call object
527 * @returns the pending call object
530 dbus_pending_call_ref (DBusPendingCall *pending)
532 _dbus_return_val_if_fail (pending != NULL, NULL);
534 _dbus_atomic_inc (&pending->refcount);
536 return pending;
540 * Decrements the reference count on a pending call,
543 * @param pending the pending call object
546 dbus_pending_call_unref (DBusPendingCall *pending)
550 _dbus_return_if_fail (pending != NULL);
552 last_unref = (_dbus_atomic_dec (&pending->refcount) == 1);
555 _dbus_pending_call_last_unref(pending);
560 * received or the pending call times out.
562 * @param pending the pending call
569 dbus_pending_call_set_notify (DBusPendingCall *pending,
574 _dbus_return_val_if_fail (pending != NULL, FALSE);
576 CONNECTION_LOCK (pending->connection);
579 if (!_dbus_pending_call_set_data_unlocked (pending, notify_user_data_slot,
583 pending->function = function;
585 CONNECTION_UNLOCK (pending->connection);
591 * Cancels the pending call, such that any reply or error received
598 * Note that canceling a pending call will <em>not</em> simulate a
603 * @param pending the pending call
606 dbus_pending_call_cancel (DBusPendingCall *pending)
608 _dbus_return_if_fail (pending != NULL);
610 _dbus_connection_remove_pending_call (pending->connection,
611 pending);
615 * Checks whether the pending call has received a reply
618 * @param pending the pending call
622 dbus_pending_call_get_completed (DBusPendingCall *pending)
626 _dbus_return_val_if_fail (pending != NULL, FALSE);
628 CONNECTION_LOCK (pending->connection);
629 completed = pending->completed;
630 CONNECTION_UNLOCK (pending->connection);
638 * function can only be called once per pending call, since the reply
641 * @param pending the pending call
645 dbus_pending_call_steal_reply (DBusPendingCall *pending)
649 _dbus_return_val_if_fail (pending != NULL, NULL);
650 _dbus_return_val_if_fail (pending->completed, NULL);
651 _dbus_return_val_if_fail (pending->reply != NULL, NULL);
653 CONNECTION_LOCK (pending->connection);
655 message = pending->reply;
656 pending->reply = NULL;
658 CONNECTION_UNLOCK (pending->connection);
664 * Block until the pending call is completed. The blocking is as with
669 * If the pending call is already completed, this function returns
673 * really only use time remaining since the pending call was created.
676 * @param pending the pending call
679 dbus_pending_call_block (DBusPendingCall *pending)
681 _dbus_return_if_fail (pending != NULL);
683 _dbus_connection_block_pending_call (pending);
734 * the pending call is finalized. The slot number
737 * @param pending the pending_call
744 dbus_pending_call_set_data (DBusPendingCall *pending,
751 _dbus_return_val_if_fail (pending != NULL, FALSE);
755 CONNECTION_LOCK (pending->connection);
756 retval = _dbus_pending_call_set_data_unlocked (pending, slot, data, free_data_func);
757 CONNECTION_UNLOCK (pending->connection);
765 * @param pending the pending_call
770 dbus_pending_call_get_data (DBusPendingCall *pending,
775 _dbus_return_val_if_fail (pending != NULL, NULL);
777 CONNECTION_LOCK (pending->connection);
779 &pending->slot_list,
781 CONNECTION_UNLOCK (pending->connection);