diff --git a/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/Executes.kt b/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/Executes.kt index 902910c..3dfd890 100644 --- a/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/Executes.kt +++ b/src/commonMain/kotlin/com/github/insanusmokrassar/krontab/Executes.kt @@ -1,27 +1,25 @@ package com.github.insanusmokrassar.krontab -suspend inline fun executeWith( - scheduler: CronDateTimeScheduler, - noinline block: suspend () -> Boolean -) = scheduler.doInLoop(block) - -suspend inline fun executeInfinity( - scheduleConfig: String, - noinline block: suspend () -> Unit -) = createCronDateTimeScheduler(scheduleConfig).doInLoop { +suspend inline fun CronDateTimeScheduler.executeInfinity(noinline block: suspend () -> Unit) = doInLoop { block() true } +suspend inline fun executeInfinity( + scheduleConfig: String, + noinline block: suspend () -> Unit +) = createCronDateTimeScheduler(scheduleConfig).executeInfinity(block) +suspend inline fun CronDateTimeScheduler.executeWhile(noinline block: suspend () -> Boolean) = doInLoop(block) suspend inline fun executeWhile( scheduleConfig: String, noinline block: suspend () -> Boolean -) = createCronDateTimeScheduler(scheduleConfig).doInLoop(block) +) = createCronDateTimeScheduler(scheduleConfig).executeWhile(block) -suspend inline fun executeOnce( - scheduleConfig: String, - noinline block: suspend () -> Unit -) = createCronDateTimeScheduler(scheduleConfig).doInLoop { +suspend inline fun CronDateTimeScheduler.executeOnce(noinline block: suspend () -> Unit) = doInLoop { block() false } +suspend inline fun executeOnce( + scheduleConfig: String, + noinline block: suspend () -> Unit +) = createCronDateTimeScheduler(scheduleConfig).executeOnce(block)