Lines Matching refs:loop
130 DBusLoop *loop; in _dbus_loop_new() local
132 loop = dbus_new0 (DBusLoop, 1); in _dbus_loop_new()
133 if (loop == NULL) in _dbus_loop_new()
136 loop->watches = _dbus_hash_table_new (DBUS_HASH_INT, NULL, in _dbus_loop_new()
139 loop->socket_set = _dbus_socket_set_new (0); in _dbus_loop_new()
141 if (loop->watches == NULL || loop->socket_set == NULL) in _dbus_loop_new()
143 if (loop->watches != NULL) in _dbus_loop_new()
144 _dbus_hash_table_unref (loop->watches); in _dbus_loop_new()
146 if (loop->socket_set != NULL) in _dbus_loop_new()
147 _dbus_socket_set_free (loop->socket_set); in _dbus_loop_new()
149 dbus_free (loop); in _dbus_loop_new()
153 loop->refcount = 1; in _dbus_loop_new()
155 return loop; in _dbus_loop_new()
159 _dbus_loop_ref (DBusLoop *loop) in _dbus_loop_ref() argument
161 _dbus_assert (loop != NULL); in _dbus_loop_ref()
162 _dbus_assert (loop->refcount > 0); in _dbus_loop_ref()
164 loop->refcount += 1; in _dbus_loop_ref()
166 return loop; in _dbus_loop_ref()
170 _dbus_loop_unref (DBusLoop *loop) in _dbus_loop_unref() argument
172 _dbus_assert (loop != NULL); in _dbus_loop_unref()
173 _dbus_assert (loop->refcount > 0); in _dbus_loop_unref()
175 loop->refcount -= 1; in _dbus_loop_unref()
176 if (loop->refcount == 0) in _dbus_loop_unref()
178 while (loop->need_dispatch) in _dbus_loop_unref()
180 DBusConnection *connection = _dbus_list_pop_first (&loop->need_dispatch); in _dbus_loop_unref()
185 _dbus_hash_table_unref (loop->watches); in _dbus_loop_unref()
186 _dbus_socket_set_free (loop->socket_set); in _dbus_loop_unref()
187 dbus_free (loop); in _dbus_loop_unref()
192 ensure_watch_table_entry (DBusLoop *loop, in ensure_watch_table_entry() argument
197 watches = _dbus_hash_table_lookup_int (loop->watches, fd); in ensure_watch_table_entry()
206 if (!_dbus_hash_table_insert_int (loop->watches, fd, watches)) in ensure_watch_table_entry()
217 cull_watches_for_invalid_fd (DBusLoop *loop, in cull_watches_for_invalid_fd() argument
224 watches = _dbus_hash_table_lookup_int (loop->watches, fd); in cull_watches_for_invalid_fd()
234 _dbus_hash_table_remove_int (loop->watches, fd); in cull_watches_for_invalid_fd()
238 gc_watch_table_entry (DBusLoop *loop, in gc_watch_table_entry() argument
250 _dbus_hash_table_remove_int (loop->watches, fd); in gc_watch_table_entry()
255 refresh_watches_for_fd (DBusLoop *loop, in refresh_watches_for_fd() argument
266 watches = _dbus_hash_table_lookup_int (loop->watches, fd); in refresh_watches_for_fd()
285 _dbus_socket_set_enable (loop->socket_set, fd, flags); in refresh_watches_for_fd()
287 _dbus_socket_set_disable (loop->socket_set, fd); in refresh_watches_for_fd()
291 _dbus_loop_add_watch (DBusLoop *loop, in _dbus_loop_add_watch() argument
300 watches = ensure_watch_table_entry (loop, fd); in _dbus_loop_add_watch()
308 gc_watch_table_entry (loop, watches, fd); in _dbus_loop_add_watch()
315 if (!_dbus_socket_set_add (loop->socket_set, fd, in _dbus_loop_add_watch()
319 _dbus_hash_table_remove_int (loop->watches, fd); in _dbus_loop_add_watch()
326 refresh_watches_for_fd (loop, watches, fd); in _dbus_loop_add_watch()
329 loop->callback_list_serial += 1; in _dbus_loop_add_watch()
330 loop->watch_count += 1; in _dbus_loop_add_watch()
335 _dbus_loop_toggle_watch (DBusLoop *loop, in _dbus_loop_toggle_watch() argument
338 refresh_watches_for_fd (loop, NULL, dbus_watch_get_socket (watch)); in _dbus_loop_toggle_watch()
342 _dbus_loop_remove_watch (DBusLoop *loop, in _dbus_loop_remove_watch() argument
355 watches = _dbus_hash_table_lookup_int (loop->watches, fd); in _dbus_loop_remove_watch()
368 loop->callback_list_serial += 1; in _dbus_loop_remove_watch()
369 loop->watch_count -= 1; in _dbus_loop_remove_watch()
374 if (gc_watch_table_entry (loop, watches, fd)) in _dbus_loop_remove_watch()
376 _dbus_socket_set_remove (loop->socket_set, fd); in _dbus_loop_remove_watch()
390 _dbus_loop_add_timeout (DBusLoop *loop, in _dbus_loop_add_timeout() argument
399 if (_dbus_list_append (&loop->timeouts, tcb)) in _dbus_loop_add_timeout()
401 loop->callback_list_serial += 1; in _dbus_loop_add_timeout()
402 loop->timeout_count += 1; in _dbus_loop_add_timeout()
414 _dbus_loop_remove_timeout (DBusLoop *loop, in _dbus_loop_remove_timeout() argument
419 link = _dbus_list_get_first_link (&loop->timeouts); in _dbus_loop_remove_timeout()
422 DBusList *next = _dbus_list_get_next_link (&loop->timeouts, link); in _dbus_loop_remove_timeout()
427 _dbus_list_remove_link (&loop->timeouts, link); in _dbus_loop_remove_timeout()
428 loop->callback_list_serial += 1; in _dbus_loop_remove_timeout()
429 loop->timeout_count -= 1; in _dbus_loop_remove_timeout()
535 _dbus_loop_dispatch (DBusLoop *loop) in _dbus_loop_dispatch() argument
539 _dbus_verbose (" %d connections to dispatch\n", _dbus_list_get_length (&loop->need_dispatch)); in _dbus_loop_dispatch()
542 if (loop->need_dispatch == NULL) in _dbus_loop_dispatch()
546 while (loop->need_dispatch != NULL) in _dbus_loop_dispatch()
548 DBusConnection *connection = _dbus_list_pop_first (&loop->need_dispatch); in _dbus_loop_dispatch()
573 _dbus_loop_queue_dispatch (DBusLoop *loop, in _dbus_loop_queue_dispatch() argument
576 if (_dbus_list_append (&loop->need_dispatch, connection)) in _dbus_loop_queue_dispatch()
590 _dbus_loop_iterate (DBusLoop *loop, in _dbus_loop_iterate() argument
605 orig_depth = loop->depth; in _dbus_loop_iterate()
609 block, loop->depth, loop->timeout_count, loop->watch_count); in _dbus_loop_iterate()
612 if (_dbus_hash_table_get_n_entries (loop->watches) == 0 && in _dbus_loop_iterate()
613 loop->timeouts == NULL) in _dbus_loop_iterate()
617 if (loop->timeout_count > 0) in _dbus_loop_iterate()
624 link = _dbus_list_get_first_link (&loop->timeouts); in _dbus_loop_iterate()
627 DBusList *next = _dbus_list_get_next_link (&loop->timeouts, link); in _dbus_loop_iterate()
663 if (!block || loop->need_dispatch != NULL) in _dbus_loop_iterate()
674 if (loop->oom_watch_pending) in _dbus_loop_iterate()
681 n_ready = _dbus_socket_set_poll (loop->socket_set, ready_fds, in _dbus_loop_iterate()
685 if (loop->oom_watch_pending) in _dbus_loop_iterate()
689 loop->oom_watch_pending = FALSE; in _dbus_loop_iterate()
691 _dbus_hash_iter_init (loop->watches, &hash_iter); in _dbus_loop_iterate()
717 refresh_watches_for_fd (loop, watches, fd); in _dbus_loop_iterate()
724 initial_serial = loop->callback_list_serial; in _dbus_loop_iterate()
726 if (loop->timeout_count > 0) in _dbus_loop_iterate()
734 link = _dbus_list_get_first_link (&loop->timeouts); in _dbus_loop_iterate()
737 DBusList *next = _dbus_list_get_next_link (&loop->timeouts, link); in _dbus_loop_iterate()
740 if (initial_serial != loop->callback_list_serial) in _dbus_loop_iterate()
743 if (loop->depth != orig_depth) in _dbus_loop_iterate()
799 if (initial_serial != loop->callback_list_serial) in _dbus_loop_iterate()
802 if (loop->depth != orig_depth) in _dbus_loop_iterate()
809 cull_watches_for_invalid_fd (loop, ready_fds[i].fd); in _dbus_loop_iterate()
822 watches = _dbus_hash_table_lookup_int (loop->watches, in _dbus_loop_iterate()
847 loop->oom_watch_pending = TRUE; in _dbus_loop_iterate()
859 if (initial_serial != loop->callback_list_serial || in _dbus_loop_iterate()
860 loop->depth != orig_depth) in _dbus_loop_iterate()
863 refresh_watches_for_fd (loop, NULL, ready_fds[i].fd); in _dbus_loop_iterate()
871 refresh_watches_for_fd (loop, watches, ready_fds[i].fd); in _dbus_loop_iterate()
880 if (_dbus_loop_dispatch (loop)) in _dbus_loop_iterate()
891 _dbus_loop_run (DBusLoop *loop) in _dbus_loop_run() argument
895 _dbus_assert (loop->depth >= 0); in _dbus_loop_run()
897 _dbus_loop_ref (loop); in _dbus_loop_run()
899 our_exit_depth = loop->depth; in _dbus_loop_run()
900 loop->depth += 1; in _dbus_loop_run()
903 loop->depth - 1, loop->depth); in _dbus_loop_run()
905 while (loop->depth != our_exit_depth) in _dbus_loop_run()
906 _dbus_loop_iterate (loop, TRUE); in _dbus_loop_run()
908 _dbus_loop_unref (loop); in _dbus_loop_run()
912 _dbus_loop_quit (DBusLoop *loop) in _dbus_loop_quit() argument
914 _dbus_assert (loop->depth > 0); in _dbus_loop_quit()
916 loop->depth -= 1; in _dbus_loop_quit()
919 loop->depth + 1, loop->depth); in _dbus_loop_quit()