Lines Matching defs:manager
78 isc_taskmgr_t * manager;
90 /* Locked by task manager lock. */
112 /* Locked by task manager lock. */
142 isc_taskmgr_t *manager = task->manager;
151 LOCK(&manager->lock);
152 UNLINK(manager->tasks, task, link);
154 if (FINISHED(manager)) {
157 * task manager is exiting. Wake up
161 BROADCAST(&manager->work_available);
164 UNLOCK(&manager->lock);
168 isc_mem_put(manager->mctx, task, sizeof(*task));
172 isc_task_create(isc_taskmgr_t *manager, unsigned int quantum,
179 REQUIRE(VALID_MANAGER(manager));
182 task = isc_mem_get(manager->mctx, sizeof(*task));
186 task->manager = manager;
189 isc_mem_put(manager->mctx, task, sizeof(*task));
205 LOCK(&manager->lock);
206 if (!manager->exiting) {
208 task->quantum = manager->default_quantum;
209 APPEND(manager->tasks, task, link);
212 UNLOCK(&manager->lock);
216 isc_mem_put(manager->mctx, task, sizeof(*task));
284 isc_taskmgr_t *manager = task->manager;
286 REQUIRE(VALID_MANAGER(manager));
291 LOCK(&manager->lock);
293 ENQUEUE(manager->ready_tasks, task, ready_link);
295 SIGNAL(&manager->work_available);
298 UNLOCK(&manager->lock);
411 * ready requires locking the manager. If we tried to do
632 event = isc_event_allocate(task->manager->mctx,
650 isc_mem_put(task->manager->mctx, event, sizeof(*event));
728 dispatch(isc_taskmgr_t *manager) {
735 REQUIRE(VALID_MANAGER(manager));
790 LOCK(&manager->lock);
791 while (!FINISHED(manager)) {
796 * the task while only holding the manager lock, and then
800 while ((EMPTY(manager->ready_tasks) ||
801 manager->exclusive_requested) &&
802 !FINISHED(manager))
807 WAIT(&manager->work_available, &manager->lock);
814 EMPTY(manager->ready_tasks))
820 task = HEAD(manager->ready_tasks);
831 * Note we only unlock the manager lock if we actually
832 * have a task to do. We must reacquire the manager
835 DEQUEUE(manager->ready_tasks, task, ready_link);
836 manager->tasks_running++;
837 UNLOCK(&manager->lock);
948 LOCK(&manager->lock);
949 manager->tasks_running--;
951 if (manager->exclusive_requested &&
952 manager->tasks_running == 1) {
953 SIGNAL(&manager->exclusive_granted);
977 ENQUEUE(manager->ready_tasks, task,
986 ISC_LIST_APPENDLIST(manager->ready_tasks, ready_tasks, ready_link);
988 UNLOCK(&manager->lock);
997 isc_taskmgr_t *manager = uap;
1002 dispatch(manager);
1012 manager_free(isc_taskmgr_t *manager) {
1016 (void)isc_condition_destroy(&manager->exclusive_granted);
1017 (void)isc_condition_destroy(&manager->work_available);
1018 isc_mem_free(manager->mctx, manager->threads);
1020 DESTROYLOCK(&manager->lock);
1021 manager->magic = 0;
1022 mctx = manager->mctx;
1023 isc_mem_put(mctx, manager, sizeof(*manager));
1033 isc_taskmgr_t *manager;
1036 * Create a new task manager.
1054 manager = isc_mem_get(mctx, sizeof(*manager));
1055 if (manager == NULL)
1057 manager->magic = TASK_MANAGER_MAGIC;
1058 manager->mctx = NULL;
1059 result = isc_mutex_init(&manager->lock);
1064 manager->workers = 0;
1065 manager->threads = isc_mem_allocate(mctx,
1067 if (manager->threads == NULL) {
1071 if (isc_condition_init(&manager->work_available) != ISC_R_SUCCESS) {
1079 if (isc_condition_init(&manager->exclusive_granted) != ISC_R_SUCCESS) {
1090 manager->default_quantum = default_quantum;
1091 INIT_LIST(manager->tasks);
1092 INIT_LIST(manager->ready_tasks);
1093 manager->tasks_running = 0;
1094 manager->exclusive_requested = ISC_FALSE;
1095 manager->exiting = ISC_FALSE;
1097 isc_mem_attach(mctx, &manager->mctx);
1100 LOCK(&manager->lock);
1105 if (isc_thread_create(run, manager,
1106 &manager->threads[manager->workers]) ==
1108 manager->workers++;
1112 UNLOCK(&manager->lock);
1115 manager_free(manager);
1120 manager->refs = 1;
1121 taskmgr = manager;
1124 *managerp = manager;
1130 (void)isc_condition_destroy(&manager->work_available);
1132 isc_mem_free(mctx, manager->threads);
1134 DESTROYLOCK(&manager->lock);
1137 isc_mem_put(mctx, manager, sizeof(*manager));
1143 isc_taskmgr_t *manager;
1152 manager = *managerp;
1153 REQUIRE(VALID_MANAGER(manager));
1158 if (manager->refs > 1) {
1159 manager->refs--;
1169 * task manager, it should ask some non-worker thread to call
1180 * task manager lock and a task lock at the same time.
1183 LOCK(&manager->lock);
1188 INSIST(!manager->exiting);
1189 manager->exiting = ISC_TRUE;
1195 for (task = HEAD(manager->tasks);
1200 ENQUEUE(manager->ready_tasks, task, ready_link);
1207 * it will cause the workers to see manager->exiting.
1209 BROADCAST(&manager->work_available);
1210 UNLOCK(&manager->lock);
1215 for (i = 0; i < manager->workers; i++)
1216 (void)isc_thread_join(manager->threads[i], NULL);
1221 UNLOCK(&manager->lock);
1224 if (!ISC_LIST_EMPTY(manager->tasks))
1226 INSIST(ISC_LIST_EMPTY(manager->tasks));
1229 manager_free(manager);
1244 isc_taskmgr_t *manager = taskmgr;
1249 dispatch(manager);
1259 isc_taskmgr_t *manager = task->manager;
1261 LOCK(&manager->lock);
1262 if (manager->exclusive_requested) {
1263 UNLOCK(&manager->lock);
1266 manager->exclusive_requested = ISC_TRUE;
1267 while (manager->tasks_running > 1) {
1268 WAIT(&manager->exclusive_granted, &manager->lock);
1270 UNLOCK(&manager->lock);
1280 isc_taskmgr_t *manager = task->manager;
1282 LOCK(&manager->lock);
1283 REQUIRE(manager->exclusive_requested);
1284 manager->exclusive_requested = ISC_FALSE;
1285 BROADCAST(&manager->work_available);
1286 UNLOCK(&manager->lock);