mirror of
https://github.com/openclaw/openclaw.git
synced 2026-05-09 15:04:33 +00:00
refactor(src): split oversized modules
This commit is contained in:
14
src/cron/service/locked.ts
Normal file
14
src/cron/service/locked.ts
Normal file
@@ -0,0 +1,14 @@
|
||||
import type { CronServiceState } from "./state.js";
|
||||
|
||||
export async function locked<T>(
|
||||
state: CronServiceState,
|
||||
fn: () => Promise<T>,
|
||||
): Promise<T> {
|
||||
const next = state.op.then(fn, fn);
|
||||
// Keep the chain alive even when the operation fails.
|
||||
state.op = next.then(
|
||||
() => undefined,
|
||||
() => undefined,
|
||||
);
|
||||
return (await next) as T;
|
||||
}
|
||||
Reference in New Issue
Block a user