Add an option to display the version string.
[beanstalkd.git] / job.h
blob670b8ef924ab228ef427d95746a09ca9666bf639
1 /* job.h - a job in the queue */
3 /* Copyright (C) 2007 Keith Rarick and Philotic Inc.
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
19 #ifndef job_h
20 #define job_h
22 #include <time.h>
24 typedef struct job *job;
25 typedef int(*job_cmp_fn)(job, job);
27 #include "tube.h"
29 #define JOB_STATE_INVALID 0
30 #define JOB_STATE_READY 1
31 #define JOB_STATE_RESERVED 2
32 #define JOB_STATE_BURIED 3
33 #define JOB_STATE_DELAYED 4
35 struct job {
36 job prev, next; /* linked list of jobs */
37 unsigned long long int id;
38 unsigned int pri;
39 unsigned int delay;
40 unsigned int ttr;
41 int body_size;
42 time_t creation;
43 time_t deadline;
44 unsigned int timeout_ct;
45 unsigned int release_ct;
46 unsigned int bury_ct;
47 unsigned int kick_ct;
48 tube tube;
49 void *reserver;
50 char state;
51 job ht_next; /* Next job in a hash table list */
52 char body[];
55 job allocate_job(int body_size);
56 job make_job(unsigned int pri, unsigned int delay, unsigned int ttr,
57 int body_size, tube tube);
58 void job_free(job j);
60 /* Lookup a job by job ID */
61 job job_find(unsigned long long int job_id);
63 int job_pri_cmp(job a, job b);
64 int job_delay_cmp(job a, job b);
66 job job_copy(job j);
68 const char * job_state(job j);
70 int job_list_any_p(job head);
71 job job_remove(job j);
72 void job_insert(job head, job j);
74 unsigned long long int total_jobs();
76 void job_init();
78 #endif /*job_h*/