summaryrefslogtreecommitdiff
path: root/jobqueue.h
blob: 9f2c20ca366e1f95025d95132591e92bb22c595d (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#ifndef _JOB_QUEUE_H_
#define _JOB_QUEUE_H_

#include "executor.h"

typedef struct JobQueue JobQueue;

/* A job queue has the property that no more than one
 * job will be active at the same time. So if the currently
 * running task knows that some object will only be touched by itself
 * and other tasks in the same queue, it doesn't have to lock it.
 *
 * Also, the task can safely cancel other jobs in the queue. The
 * pointer you get back is guaranteed to be valid until the corresponding
 * task has returned
 */
JobQueue *job_queue_new (Executor *executor);
gpointer  job_queue_add (JobQueue *queue,
			 ExecutorJob job,
			 gpointer data);
void	  job_queue_remove (JobQueue *queue,
			    gpointer  job);
void      job_queue_free (JobQueue *queue);

#endif