Main Page | Alphabetical List | Data Structures | File List | Data Fields | Globals | Related Pages

work_queue.h File Reference


Detailed Description

A master-worker library.

The work queue provides an implementation of the master-worker computing model using TCP sockets, Unix applications, and files as intermediate buffers. A master process uses work_queue_create to create a queue, then work_queue_submit to submit tasks. Once tasks are running, call work_queue_wait to wait for completion. The generic worker program can be run on any machine, and simply needs to be told the host and port of the master.

#include "timestamp.h"

Go to the source code of this file.

Data Structures

struct  task_file
 A file for input to a task. More...
struct  work_queue_task
 A task description. More...
struct  work_queue_stats
 Statistics describing a work queue. More...

Functions

work_queue * work_queue_create (int port)
 Create a new work queue.
void work_queue_delete (struct work_queue *q)
 Delete a work queue.
void work_queue_submit (struct work_queue *q, struct work_queue_task *t)
 Submit a job to a work queue.
work_queue_taskwork_queue_wait (struct work_queue *q)
 Wait for tasks to complete.
work_queue_taskwork_queue_wait_time (struct work_queue *q, time_t stoptime)
 Wait for tasks to complete.
work_queue_taskwork_queue_task_create (const char *tag, const char *command, const struct task_file *input_files, const int num_inputs, const char *output_files, int priority)
 Create a new task specification.
void work_queue_task_delete (struct work_queue_task *t)
 Delete a task specification.
void work_queue_get_stats (struct work_queue *q, struct work_queue_stats *s)
 Get queue statistics.


Function Documentation

struct work_queue* work_queue_create int  port  ) 
 

Create a new work queue.

Parameters:
port The port number to listen on, or zero to choose a default.
Returns:
A new work queue, or zero if it could not be created.

void work_queue_delete struct work_queue *  q  ) 
 

Delete a work queue.

Parameters:
q The work queue to delete.

void work_queue_submit struct work_queue *  q,
struct work_queue_task t
 

Submit a job to a work queue.

Parameters:
q A work queue returned from work_queue_create.
t A task description returned from work_queue_task_create.

struct work_queue_task* work_queue_wait struct work_queue *  q  ) 
 

Wait for tasks to complete.

This call will block indefinitely until a task completes.

Parameters:
q The work queue to wait on.
Returns:
A completed task description, or null if the queue is empty.

struct work_queue_task* work_queue_wait_time struct work_queue *  q,
time_t  stoptime
 

Wait for tasks to complete.

This call will block indefinitely until a task completes.

Parameters:
q The work queue to wait on.
Returns:
A completed task description, or null if the queue is empty.

struct work_queue_task* work_queue_task_create const char *  tag,
const char *  command,
const struct task_file input_files,
const int  num_inputs,
const char *  output_files,
int  priority
 

Create a new task specification.

Once created, the task may be passed to work_queue_submit.

Parameters:
tag A free-form description of the task, for the caller's record keeping.
command The command line to be executed.
input_files The files that must be transferred to the remote host before execution, including the executable. If the files should have a different name locally than remotely, specify this by stating localname=remotename.
output_files The files that must be returned upon completion, separated by commas.If the files should have a different name locally than remotely, specify this by stating localname=remotename.
priority An integer describing the relative priority of the job, where higher numbers will be executed sooner.

void work_queue_task_delete struct work_queue_task t  ) 
 

Delete a task specification.

This may be called on tasks after they are returned from work_queue_wait.

Parameters:
t The task specification to delete.

void work_queue_get_stats struct work_queue *  q,
struct work_queue_stats s
 

Get queue statistics.

Parameters:
q The queue to query.
s A pointer to a buffer that will be filed with statistics.


Generated on Fri Jun 5 11:10:55 2009 for cctools by  doxygen 1.3.9.1