forked from beanstalkd/beanstalkd
-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move job reservation logic into its own module.
- Loading branch information
Keith Rarick
committed
Oct 1, 2007
1 parent
b9270f3
commit a19c8eb
Showing
7 changed files
with
70 additions
and
52 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,50 @@ | ||
/* reserve.c - job reservations */ | ||
|
||
#include "prot.h" | ||
#include "reserve.h" | ||
|
||
int | ||
has_reserved_job(conn c) | ||
{ | ||
return !!c->reserved_job; | ||
} | ||
|
||
/* return the reserved job with the earliest deadline, | ||
* or NULL if there's no reserved job */ | ||
job | ||
soonest_job(conn c) | ||
{ | ||
return c->reserved_job; | ||
} | ||
|
||
void | ||
enqueue_reserved_jobs(conn c) | ||
{ | ||
enqueue_job(c->reserved_job); | ||
c->reserved_job = NULL; | ||
} | ||
|
||
int | ||
has_reserved_this_job(conn c, job j) | ||
{ | ||
return c->reserved_job == j; | ||
} | ||
|
||
job | ||
remove_reserved_job(conn c, unsigned long long int id) | ||
{ | ||
job j; | ||
|
||
if (!c->reserved_job) return NULL; | ||
if (id != c->reserved_job->id) return NULL; | ||
j = c->reserved_job; | ||
c->reserved_job = NULL; | ||
return j; | ||
} | ||
|
||
void | ||
job_remove(conn c, job j) | ||
{ | ||
if (c->reserved_job == j) c->reserved_job = NULL; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
/* reserve.h - job reservations header */ | ||
|
||
#ifndef reserve_h | ||
#define reserve_H | ||
|
||
#include "job.h" | ||
#include "conn.h" | ||
|
||
int has_reserved_job(conn c); | ||
job soonest_job(conn c); | ||
void enqueue_reserved_jobs(conn c); | ||
int has_reserved_this_job(conn c, job j); | ||
job remove_reserved_job(conn c, unsigned long long int id); | ||
void job_remove(conn c, job j); | ||
|
||
|
||
#endif /*reserve_h*/ |
Empty file.