From 67677c3c923f6e3e949532b642952997a951cc4d Mon Sep 17 00:00:00 2001 From: Philipp Moritz Date: Tue, 4 Oct 2016 17:06:52 -0700 Subject: [PATCH] update documentation and common --- common | 2 +- photon_scheduler.c | 11 ++++++----- photon_scheduler.h | 24 +++++++++++++++++++++--- 3 files changed, 28 insertions(+), 9 deletions(-) diff --git a/common b/common index 49ac871ef..4329afbd5 160000 --- a/common +++ b/common @@ -1 +1 @@ -Subproject commit 49ac871ef6a6751835dcd8448f1d67ef4d6c82ad +Subproject commit 4329afbd53449412b08e64d4057a2857393c2212 diff --git a/photon_scheduler.c b/photon_scheduler.c index e6b6cdad2..7d9b5f7ef 100644 --- a/photon_scheduler.c +++ b/photon_scheduler.c @@ -32,9 +32,8 @@ struct local_scheduler_state { UT_array *available_worker_queue; }; -local_scheduler_state *init_local_scheduler(event_loop *loop, - const char *redis_addr, - int redis_port) { +local_scheduler_state * +init_local_scheduler(event_loop *loop, const char *redis_addr, int redis_port) { local_scheduler_state *state = malloc(sizeof(local_scheduler_state)); state->db = db_connect(redis_addr, redis_port, "photon", "", -1); db_attach(state->db, loop); @@ -47,7 +46,8 @@ void handle_submit_task(local_scheduler_state *s, task_spec *task) { /* Assign this task to an available worker. If there are no available workers, * then add this task to the local task queue. */ task_iid task_iid = globally_unique_id(); - task_instance *instance = make_task_instance(task_iid, task, TASK_WAITING, NIL_ID); + task_instance *instance = + make_task_instance(task_iid, task, TASK_STATUS_WAITING, NIL_ID); if (utarray_len(s->available_worker_queue) > 0) { /* Get the last available worker in the available worker queue. */ available_worker *worker = @@ -143,7 +143,8 @@ void start_server(const char *socket_name, const char *redis_addr, int redis_port) { int fd = bind_ipc_sock(socket_name); event_loop *loop = event_loop_create(); - local_scheduler_state *state = init_local_scheduler(loop, redis_addr, redis_port); + local_scheduler_state *state = + init_local_scheduler(loop, redis_addr, redis_port); /* Run event loop. */ event_loop_add_file(loop, fd, EVENT_LOOP_READ, new_client_connection, state); diff --git a/photon_scheduler.h b/photon_scheduler.h index bef1f42d9..54905bb88 100644 --- a/photon_scheduler.h +++ b/photon_scheduler.h @@ -5,14 +5,32 @@ typedef struct local_scheduler_state local_scheduler_state; -/* Establish a connection to a new client. */ +/** + * Establish a connection to a new client. + * + * @param loop Event loop of the local scheduler. + * @param listener_socket Socket the local scheduler is listening on for new + * client requests. + * @param context State of the local scheduler. + * @param events Flag for events that are available on the listener socket. + */ void new_client_connection(event_loop *loop, int listener_sock, void *context, int events); -/* Assign a task to a worker. */ +/** + * Assign a task to a worker. + * + * @param s State of the local scheduler. + * @param client_sock Socket by which the worker is connected. + */ void handle_get_task(local_scheduler_state *s, int client_sock); -/* Handle incoming submit request by a worker. */ +/** + * Handle incoming submit request by a worker. + * + * @param s State of the local scheduler. + * @param task Task specification of the task to be submitted. + */ void handle_submit_task(local_scheduler_state *s, task_spec *task); #endif /* PHOTON_SCHEDULER_H */