import * as tsplus_module_1 from "@effect/core/stm/TSemaphore/operations/acquireN";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/commit";
import * as tsplus_module_3 from "@effect/core/stm/TSemaphore/operations/releaseN";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/acquireReleaseInterruptible";
/**
 * Returns a scoped effect that describes acquiring the specified number of
 * permits and releasing them when the scope is closed.
 *
 * @tsplus fluent ets/TSemaphore withPermitsScoped
 */

export function withPermitsScoped_(self, permits, __tsplusTrace) {
  return tsplus_module_4.acquireReleaseInterruptible(() => tsplus_module_2.commit(tsplus_module_1.acquireN_(self, permits), __tsplusTrace), () => tsplus_module_2.commit(tsplus_module_3.releaseN_(self, permits), __tsplusTrace), __tsplusTrace);
}
/**
 * Returns a scoped effect that describes acquiring the specified number of
 * permits and releasing them when the scope is closed.
 *
 * @tsplus static ets/TSemaphore/Aspects withPermitsScoped
 */

export const withPermitsScoped = (permits, __tsplusTrace) => self => withPermitsScoped_(self, permits, __tsplusTrace);
//# sourceMappingURL=withPermitsScoped.mjs.map