Lines Matching defs:manager
64 isc_timermgr_t * manager;
69 /*! Locked by manager lock. */
89 /* Locked by manager lock. */
113 isc_timermgr_t *manager;
130 manager = timer->manager;
134 * If the manager was timed wait, we may need to signal the
135 * manager to force a wakeup.
137 timedwait = ISC_TF(manager->nscheduled > 0 &&
138 isc_time_seconds(&manager->due) != 0);
174 isc_heap_increased(manager->heap, timer->index);
177 isc_heap_decreased(manager->heap, timer->index);
185 result = isc_heap_insert(manager->heap, timer);
190 manager->nscheduled++;
200 * run thread, or explicitly setting the value in the manager.
217 result = isc_time_add(&manager->due, &fifteen, &then);
221 SIGNAL(&manager->wakeup);
233 SIGNAL(&manager->wakeup);
237 isc_time_compare(&timer->due, &manager->due) < 0)
238 manager->due = timer->due;
249 isc_timermgr_t *manager;
255 manager = timer->manager;
261 isc_heap_delete(manager->heap, timer->index);
263 INSIST(manager->nscheduled > 0);
264 manager->nscheduled--;
270 SIGNAL(&manager->wakeup);
278 isc_timermgr_t *manager = timer->manager;
284 LOCK(&manager->lock);
292 UNLINK(manager->timers, timer, link);
294 UNLOCK(&manager->lock);
299 isc_mem_put(manager->mctx, timer, sizeof(*timer));
303 isc_timer_create(isc_timermgr_t *manager, isc_timertype_t type,
313 * Create a new 'type' timer managed by 'manager'. The timers
320 REQUIRE(VALID_MANAGER(manager));
348 timer = isc_mem_get(manager->mctx, sizeof(*timer));
352 timer->manager = manager;
358 isc_mem_put(manager->mctx, timer, sizeof(*timer));
385 isc_mem_put(manager->mctx, timer, sizeof(*timer));
391 LOCK(&manager->lock);
403 APPEND(manager->timers, timer, link);
405 UNLOCK(&manager->lock);
411 isc_mem_put(manager->mctx, timer, sizeof(*timer));
426 isc_timermgr_t *manager;
436 manager = timer->manager;
437 REQUIRE(VALID_MANAGER(manager));
462 LOCK(&manager->lock);
490 UNLOCK(&manager->lock);
526 * but we cannot without locking the manager lock too, which we
581 dispatch(isc_timermgr_t *manager, isc_time_t *now) {
590 * The caller must be holding the manager lock.
593 while (manager->nscheduled > 0 && !done) {
594 timer = isc_heap_element(manager->heap, 1);
656 event = (isc_timerevent_t *)isc_event_allocate(manager->mctx,
677 isc_heap_delete(manager->heap, 1);
678 manager->nscheduled--;
693 manager->due = timer->due;
705 isc_timermgr_t *manager = uap;
709 LOCK(&manager->lock);
710 while (!manager->done) {
717 dispatch(manager, &now);
719 if (manager->nscheduled > 0) {
724 manager->due, now);
725 result = WAITUNTIL(&manager->wakeup, &manager->lock, &manager->due);
731 WAIT(&manager->wakeup, &manager->lock);
736 UNLOCK(&manager->lock);
768 isc_timermgr_t *manager;
772 * Create a timer manager.
785 manager = isc_mem_get(mctx, sizeof(*manager));
786 if (manager == NULL)
789 manager->magic = TIMER_MANAGER_MAGIC;
790 manager->mctx = NULL;
791 manager->done = ISC_FALSE;
792 INIT_LIST(manager->timers);
793 manager->nscheduled = 0;
794 isc_time_settoepoch(&manager->due);
795 manager->heap = NULL;
796 result = isc_heap_create(mctx, sooner, set_index, 0, &manager->heap);
799 isc_mem_put(mctx, manager, sizeof(*manager));
802 result = isc_mutex_init(&manager->lock);
804 isc_heap_destroy(&manager->heap);
805 isc_mem_put(mctx, manager, sizeof(*manager));
808 isc_mem_attach(mctx, &manager->mctx);
810 if (isc_condition_init(&manager->wakeup) != ISC_R_SUCCESS) {
811 isc_mem_detach(&manager->mctx);
812 DESTROYLOCK(&manager->lock);
813 isc_heap_destroy(&manager->heap);
814 isc_mem_put(mctx, manager, sizeof(*manager));
821 if (isc_thread_create(run, manager, &manager->thread) !=
823 isc_mem_detach(&manager->mctx);
824 (void)isc_condition_destroy(&manager->wakeup);
825 DESTROYLOCK(&manager->lock);
826 isc_heap_destroy(&manager->heap);
827 isc_mem_put(mctx, manager, sizeof(*manager));
835 manager->refs = 1;
836 timermgr = manager;
839 *managerp = manager;
845 isc_timermgr_poke(isc_timermgr_t *manager) {
847 REQUIRE(VALID_MANAGER(manager));
849 SIGNAL(&manager->wakeup);
851 UNUSED(manager);
857 isc_timermgr_t *manager;
861 * Destroy a timer manager.
865 manager = *managerp;
866 REQUIRE(VALID_MANAGER(manager));
868 LOCK(&manager->lock);
871 if (manager->refs > 1) {
872 manager->refs--;
873 UNLOCK(&manager->lock);
881 REQUIRE(EMPTY(manager->timers));
882 manager->done = ISC_TRUE;
887 SIGNAL(&manager->wakeup);
890 UNLOCK(&manager->lock);
896 if (isc_thread_join(manager->thread, NULL) != ISC_R_SUCCESS)
907 (void)isc_condition_destroy(&manager->wakeup);
909 DESTROYLOCK(&manager->lock);
910 isc_heap_destroy(&manager->heap);
911 manager->magic = 0;
912 mctx = manager->mctx;
913 isc_mem_put(mctx, manager, sizeof(*manager));