fixes in docs and refactor

This commit is contained in:
InsanusMokrassar 2020-07-24 15:23:44 +06:00
parent 5cc9c8278e
commit 990b0d1011

View File

@ -7,7 +7,7 @@ import kotlinx.coroutines.delay
/**
* Execute [block] once at the [KronScheduler.next] time and return result of [block] calculation.
*
* WARNING!!! If you want to launch it in parallel, you must do this explicit.
* WARNING!!! If you want to launch it in parallel, you must do this explicitly.
*/
suspend inline fun <T> KronScheduler.doOnce(noinline block: suspend () -> T): T {
delay((next() - DateTime.now()).millisecondsLong)
@ -15,12 +15,13 @@ suspend inline fun <T> KronScheduler.doOnce(noinline block: suspend () -> T): T
}
/**
* Will [createSimpleScheduler] using [scheduleConfig] and call [doOnce] on it
* Will [buildSchedule] using [scheduleConfig] and call [doOnce] on it
* @see buildSchedule
*/
suspend inline fun <T> doOnce(
scheduleConfig: String,
noinline block: suspend () -> T
) = createSimpleScheduler(scheduleConfig).doOnce(block)
) = buildSchedule(scheduleConfig).doOnce(block)
/**
* Will execute [block] while it will return true as a result of its calculation
@ -30,12 +31,14 @@ suspend inline fun KronScheduler.doWhile(noinline block: suspend () -> Boolean)
}
/**
* Will [createSimpleScheduler] using [scheduleConfig] and call [doWhile] with [block]
* Will [buildSchedule] using [scheduleConfig] and call [doWhile] with [block]
*
* @see buildSchedule
*/
suspend inline fun doWhile(
scheduleConfig: String,
noinline block: suspend () -> Boolean
) = createSimpleScheduler(scheduleConfig).doWhile(block)
) = buildSchedule(scheduleConfig).doWhile(block)
/**
* Will execute [block] without any checking of result
@ -45,9 +48,11 @@ suspend inline fun KronScheduler.doInfinity(noinline block: suspend () -> Unit)
true
}
/**
* Will [createSimpleScheduler] using [scheduleConfig] and call [doInfinity] with [block]
* Will [buildSchedule] using [scheduleConfig] and call [doInfinity] with [block]
*
* @see buildSchedule
*/
suspend inline fun doInfinity(
scheduleConfig: String,
noinline block: suspend () -> Unit
) = createSimpleScheduler(scheduleConfig).doInfinity(block)
) = buildSchedule(scheduleConfig).doInfinity(block)