import * as tsplus_module_1 from "@effect/core/io/Cause/errors";
import * as tsplus_module_2 from "@effect/core/stm/TRef/operations/unsafeGet";
import * as tsplus_module_3 from "@effect/core/stm/TRef/operations/unsafeSet";
import * as tsplus_module_4 from "@effect/core/stm/STM/operations/effect";
import { concreteTSemaphore } from "@effect/core/stm/TSemaphore/operations/_internal/TSemaphoreInternal";
/**
 * Releases the specified number of permits in a transactional context
 *
 * @tsplus fluent ets/TSemaphore releaseN
 */

export function releaseN_(self, n) {
  void 0;
  return tsplus_module_4.effect(journal => {
    if (n < 0) {
      throw new tsplus_module_1.IllegalArgumentException(`Unexpected negative value ${n} passed to releaseN`);
    }

    const current = tsplus_module_2.unsafeGet_(self.permits, journal);
    return tsplus_module_3.unsafeSet_(self.permits, current + n, journal);
  });
}
/**
 * Releases the specified number of permits in a transactional context
 *
 * @tsplus static ets/TSemaphore/Aspects releaseN
 */

export const releaseN = n => self => releaseN_(self, n);
//# sourceMappingURL=releaseN.mjs.map