Commit dcd83f0e authored by Bob Halley's avatar Bob Halley
Browse files

update

parent 50f339a7
......@@ -51,11 +51,11 @@ typedef generic_event_t nop_event_t;
typedef LIST(struct generic_event) event_list_t;
void * event_get(mem_context_t,
generic_event_t event_get(mem_context_t,
event_type_t,
event_action_t,
size_t);
void event_put(void *);
void event_put(generic_event_t *);
/***
......@@ -125,6 +125,6 @@ unsigned int task_manager_create(mem_context_t,
unsigned int,
unsigned int,
task_manager_t *);
boolean_t task_manager_destroy(task_manager_t *);
void task_manager_destroy(task_manager_t *);
#endif /* TASK_H */
......@@ -38,13 +38,17 @@
*** Tasks.
***/
void *
generic_event_t
event_get(mem_context_t mctx, event_type_t type, event_action_t action,
size_t size) {
generic_event_t event;
if (size < sizeof *event)
return (NULL);
if (type < 0)
return (NULL);
if (action == NULL)
return (NULL);
event = mem_get(mctx, size);
if (event == NULL)
return (NULL);
......@@ -57,10 +61,16 @@ event_get(mem_context_t mctx, event_type_t type, event_action_t action,
}
void
event_put(void *target) {
generic_event_t event = target;
event_put(generic_event_t *eventp) {
generic_event_t event;
REQUIRE(eventp != NULL);
event = *eventp;
REQUIRE(event != NULL);
mem_put(event->mctx, event, event->size);
*eventp = NULL;
}
......@@ -207,7 +217,7 @@ task_send_event(task_t task, generic_event_t *eventp) {
UNLOCK(&task->lock);
if (discard) {
event_put(event);
event_put(&event);
*eventp = NULL;
return (TRUE);
}
......@@ -456,7 +466,7 @@ void *task_manager_run(void *uap) {
* callback returned.
*/
if (event != NULL)
event_put(event);
event_put(&event);
else
wants_shutdown = TRUE;
......@@ -483,6 +493,7 @@ void *task_manager_run(void *uap) {
if (task->references == 0)
free_task = TRUE;
task->state = task_state_shutdown;
task->shutdown_pending = FALSE;
done = TRUE;
} else if (EMPTY(task->events) &&
!task->shutdown_pending) {
......@@ -517,7 +528,7 @@ void *task_manager_run(void *uap) {
event != NULL;
event = next_event) {
next_event = NEXT(event, link);
event_put(event);
event_put(&event);
}
}
......@@ -581,6 +592,8 @@ task_manager_create(mem_context_t mctx, unsigned int workers,
task_manager_t manager;
os_thread_t thread;
if (workers == 0)
return (0);
manager = mem_get(mctx, sizeof *manager);
if (manager == NULL)
return (0);
......@@ -632,7 +645,7 @@ task_manager_create(mem_context_t mctx, unsigned int workers,
return (started);
}
boolean_t
void
task_manager_destroy(task_manager_t *managerp) {
task_manager_t manager;
task_t task;
......@@ -700,6 +713,4 @@ task_manager_destroy(task_manager_t *managerp) {
manager_free(manager);
*managerp = NULL;
return (TRUE);
}
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment