job: Add job_sleep_ns()

There is nothing block layer specific about block_job_sleep_ns(), so
move the function to Job.

Signed-off-by: Kevin Wolf <kwolf@redhat.com>
Reviewed-by: John Snow <jsnow@redhat.com>
Reviewed-by: Max Reitz <mreitz@redhat.com>
This commit is contained in:
Kevin Wolf 2018-04-18 16:32:20 +02:00
parent da01ff7f38
commit 5d43e86e11
11 changed files with 61 additions and 50 deletions

View file

@ -133,17 +133,6 @@ void *block_job_create(const char *job_id, const BlockJobDriver *driver,
*/
void block_job_free(Job *job);
/**
* block_job_sleep_ns:
* @job: The job that calls the function.
* @ns: How many nanoseconds to stop for.
*
* Put the job to sleep (assuming that it wasn't canceled) for @ns
* %QEMU_CLOCK_REALTIME nanoseconds. Canceling the job will immediately
* interrupt the wait.
*/
void block_job_sleep_ns(BlockJob *job, int64_t ns);
/**
* block_job_yield:
* @job: The job that calls the function.

View file

@ -58,7 +58,7 @@ typedef struct Job {
Coroutine *co;
/**
* Timer that is used by @block_job_sleep_ns. Accessed under job_mutex (in
* Timer that is used by @job_sleep_ns. Accessed under job_mutex (in
* job.c).
*/
QEMUTimer sleep_timer;
@ -167,6 +167,13 @@ void job_enter_cond(Job *job, bool(*fn)(Job *job));
*/
void job_start(Job *job);
/**
* @job: The job to enter.
*
* Continue the specified job by entering the coroutine.
*/
void job_enter(Job *job);
/**
* @job: The job that is ready to pause.
*
@ -175,6 +182,16 @@ void job_start(Job *job);
*/
void coroutine_fn job_pause_point(Job *job);
/**
* @job: The job that calls the function.
* @ns: How many nanoseconds to stop for.
*
* Put the job to sleep (assuming that it wasn't canceled) for @ns
* %QEMU_CLOCK_REALTIME nanoseconds. Canceling the job will immediately
* interrupt the wait.
*/
void coroutine_fn job_sleep_ns(Job *job, int64_t ns);
/** Returns the JobType of a given Job. */
JobType job_type(const Job *job);