import * as tsplus_module_1 from "@effect/core/stm/TReentrantLock/operations/TReentrantLock/acquireWrite";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/commit";
import * as tsplus_module_3 from "@effect/core/stm/TReentrantLock/operations/TReentrantLock/releaseWrite";
import * as tsplus_module_4 from "@effect/core/io/Effect/operations/ensuring";
import * as tsplus_module_5 from "@effect/core/io/Effect/operations/zipRight";
import * as tsplus_module_6 from "@effect/core/io/Effect/operations/interruption";
/**
 * Runs the specified workflow with a write lock.
 *
 * @tsplus fluent ets/TReentrantLock withWriteLock
 */

export function withWriteLock_(self, effect, __tsplusTrace) {
  return tsplus_module_6.uninterruptibleMask(_ => tsplus_module_5.zipRight_(_.restore(() => tsplus_module_2.commit(tsplus_module_1.acquireWrite(self), __tsplusTrace), __tsplusTrace), () => tsplus_module_4.ensuring_(_.restore(() => effect, __tsplusTrace), () => tsplus_module_2.commit(tsplus_module_3.releaseWrite(self), __tsplusTrace), __tsplusTrace), __tsplusTrace), __tsplusTrace);
}
/**
 * Runs the specified workflow with a write lock.
 *
 * @tsplus static ets/TReentrantLock/Aspects withWriteLock
 */

export const withWriteLock = (effect, __tsplusTrace) => self => withWriteLock_(self, effect, __tsplusTrace);
//# sourceMappingURL=withWriteLock.mjs.map