Searching for a Utility for Dropping Semaphore with 1 Permit
Is there a a utility for a kind of "dropping semaphore" or "only allow one instance to run at once, discard all others"? The logic is simple but I wasn't sure if there was a builtin for it
let isRunning = false
const doStuff = () => {
if (isRunning) return Effect.unit()
isRunning = true
return pipe(
//......
Effect.ensuring(Effect.sync(() => (isRunning = false))),
)
}