aboutsummaryrefslogtreecommitdiff
path: root/job.c
diff options
context:
space:
mode:
Diffstat (limited to 'job.c')
-rw-r--r--job.c16
1 files changed, 13 insertions, 3 deletions
diff --git a/job.c b/job.c
index aa4c746c8a..b5bd51b0ad 100644
--- a/job.c
+++ b/job.c
@@ -157,9 +157,7 @@ static int job_txn_apply(JobTxn *txn, int fn(Job *), bool lock)
return rc;
}
-
-/* TODO Make static once the whole state machine is in job.c */
-void job_state_transition(Job *job, JobStatus s1)
+static void job_state_transition(Job *job, JobStatus s1)
{
JobStatus s0 = job->status;
assert(s1 >= 0 && s1 <= JOB_STATUS__MAX);
@@ -321,6 +319,7 @@ void *job_create(const char *job_id, const JobDriver *driver, JobTxn *txn,
notifier_list_init(&job->on_finalize_cancelled);
notifier_list_init(&job->on_finalize_completed);
notifier_list_init(&job->on_pending);
+ notifier_list_init(&job->on_ready);
job_state_transition(job, JOB_STATUS_CREATED);
aio_timer_init(qemu_get_aio_context(), &job->sleep_timer,
@@ -380,6 +379,11 @@ static void job_event_pending(Job *job)
notifier_list_notify(&job->on_pending, job);
}
+static void job_event_ready(Job *job)
+{
+ notifier_list_notify(&job->on_ready, job);
+}
+
void job_enter_cond(Job *job, bool(*fn)(Job *job))
{
if (!job_started(job)) {
@@ -799,6 +803,12 @@ static int job_transition_to_pending(Job *job)
return 0;
}
+void job_transition_to_ready(Job *job)
+{
+ job_state_transition(job, JOB_STATUS_READY);
+ job_event_ready(job);
+}
+
static void job_completed_txn_success(Job *job)
{
JobTxn *txn = job->txn;