From d1f84ee136ddde745ca8a67f2f9881940dcb5f3b Mon Sep 17 00:00:00 2001 From: InsanusMokrassar Date: Tue, 8 Oct 2019 22:15:00 +0600 Subject: [PATCH] now all executes can be applyed to CronDateTimeScheduler --- .../insanusmokrassar/krontab/Executes.kt | 26 +++++++++---------- 1 file changed, 12 insertions(+), 14 deletions(-) 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)