import * as tsplus_module_1 from "@effect/core/stm/TReentrantLock/operations/TReentrantLock/acquireRead";
import * as tsplus_module_2 from "@effect/core/stm/STM/operations/commit";
import * as tsplus_module_3 from "@effect/core/stm/TReentrantLock/operations/TReentrantLock/releaseRead";
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 read lock.
 *
 * @tsplus fluent ets/TReentrantLock withReadLock
 */

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

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