• Home
  • History
  • Annotate
  • Raw
  • Download
  • only in /netgear-R7000-V1.0.7.12_1.2.5/ap/gpl/iserver/dbus-1.6.8/dbus/

Lines Matching refs:loop

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