summaryrefslogtreecommitdiff
path: root/ext/cron/01_cron.ts
diff options
context:
space:
mode:
authorMatt Mastracci <matthew@mastracci.com>2023-12-26 18:30:26 -0700
committerGitHub <noreply@github.com>2023-12-27 02:30:26 +0100
commit0efe438f7c191d8504355e03b27fe7e3055c9387 (patch)
treeb96fe9a897eb6941c87a95a04520662d26c02fbe /ext/cron/01_cron.ts
parente33c5eb704c22fad69876e87d9b852a4e5072a7a (diff)
perf: remove opAsync (#21690)
`opAsync` requires a lookup by name on each async call. This is a mechanical translation of all opAsync calls to ensureFastOps. The `opAsync` API on Deno.core will be removed at a later time.
Diffstat (limited to 'ext/cron/01_cron.ts')
-rw-r--r--ext/cron/01_cron.ts12
1 files changed, 9 insertions, 3 deletions
diff --git a/ext/cron/01_cron.ts b/ext/cron/01_cron.ts
index 4a5250618..07b2f26eb 100644
--- a/ext/cron/01_cron.ts
+++ b/ext/cron/01_cron.ts
@@ -1,7 +1,9 @@
// Copyright 2018-2023 the Deno authors. All rights reserved. MIT license.
-// @ts-ignore internal api
-const core = Deno.core;
+import { core, internals } from "ext:core/mod.js";
+const {
+ op_cron_next,
+} = core.ensureFastOps();
export function formatToCronSchedule(
value?: number | { exact: number | number[] } | {
@@ -122,7 +124,7 @@ function cron(
return (async () => {
let success = true;
while (true) {
- const r = await core.opAsync("op_cron_next", rid, success);
+ const r = await op_cron_next(rid, success);
if (r === false) {
break;
}
@@ -138,4 +140,8 @@ function cron(
})();
}
+// For testing
+internals.formatToCronSchedule = formatToCronSchedule;
+internals.parseScheduleToString = parseScheduleToString;
+
export { cron };