effect 4.0.0-beta.17 → 4.0.0-beta.19

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/dist/Array.d.ts +127 -299
  2. package/dist/Array.d.ts.map +1 -1
  3. package/dist/Array.js +102 -62
  4. package/dist/Array.js.map +1 -1
  5. package/dist/Cache.d.ts.map +1 -1
  6. package/dist/Cache.js +5 -4
  7. package/dist/Cache.js.map +1 -1
  8. package/dist/Channel.d.ts +97 -11
  9. package/dist/Channel.d.ts.map +1 -1
  10. package/dist/Channel.js +72 -29
  11. package/dist/Channel.js.map +1 -1
  12. package/dist/Chunk.d.ts +54 -247
  13. package/dist/Chunk.d.ts.map +1 -1
  14. package/dist/Chunk.js +36 -67
  15. package/dist/Chunk.js.map +1 -1
  16. package/dist/Effect.d.ts +337 -437
  17. package/dist/Effect.d.ts.map +1 -1
  18. package/dist/Effect.js +118 -134
  19. package/dist/Effect.js.map +1 -1
  20. package/dist/Filter.d.ts +0 -33
  21. package/dist/Filter.d.ts.map +1 -1
  22. package/dist/Filter.js +0 -13
  23. package/dist/Filter.js.map +1 -1
  24. package/dist/HashMap.d.ts +15 -14
  25. package/dist/HashMap.d.ts.map +1 -1
  26. package/dist/HashMap.js +4 -4
  27. package/dist/HashMap.js.map +1 -1
  28. package/dist/Iterable.d.ts +40 -39
  29. package/dist/Iterable.d.ts.map +1 -1
  30. package/dist/Iterable.js +94 -22
  31. package/dist/Iterable.js.map +1 -1
  32. package/dist/Option.d.ts +22 -15
  33. package/dist/Option.d.ts.map +1 -1
  34. package/dist/Option.js +14 -7
  35. package/dist/Option.js.map +1 -1
  36. package/dist/Pull.d.ts.map +1 -1
  37. package/dist/Pull.js +1 -1
  38. package/dist/Pull.js.map +1 -1
  39. package/dist/Record.d.ts +24 -120
  40. package/dist/Record.d.ts.map +1 -1
  41. package/dist/Record.js +21 -41
  42. package/dist/Record.js.map +1 -1
  43. package/dist/Sink.d.ts +11 -11
  44. package/dist/Sink.d.ts.map +1 -1
  45. package/dist/Sink.js +53 -6
  46. package/dist/Sink.js.map +1 -1
  47. package/dist/Stream.d.ts +198 -386
  48. package/dist/Stream.d.ts.map +1 -1
  49. package/dist/Stream.js +103 -59
  50. package/dist/Stream.js.map +1 -1
  51. package/dist/Trie.d.ts +18 -17
  52. package/dist/Trie.d.ts.map +1 -1
  53. package/dist/Trie.js +5 -5
  54. package/dist/Trie.js.map +1 -1
  55. package/dist/TxChunk.d.ts +37 -37
  56. package/dist/TxChunk.d.ts.map +1 -1
  57. package/dist/TxChunk.js +3 -3
  58. package/dist/TxChunk.js.map +1 -1
  59. package/dist/TxDeferred.d.ts +328 -0
  60. package/dist/TxDeferred.d.ts.map +1 -0
  61. package/dist/TxDeferred.js +196 -0
  62. package/dist/TxDeferred.js.map +1 -0
  63. package/dist/TxHashMap.d.ts +84 -83
  64. package/dist/TxHashMap.d.ts.map +1 -1
  65. package/dist/TxHashMap.js +24 -24
  66. package/dist/TxHashMap.js.map +1 -1
  67. package/dist/TxHashSet.d.ts +35 -35
  68. package/dist/TxHashSet.d.ts.map +1 -1
  69. package/dist/TxHashSet.js +14 -14
  70. package/dist/TxHashSet.js.map +1 -1
  71. package/dist/TxPriorityQueue.d.ts +609 -0
  72. package/dist/TxPriorityQueue.d.ts.map +1 -0
  73. package/dist/TxPriorityQueue.js +415 -0
  74. package/dist/TxPriorityQueue.js.map +1 -0
  75. package/dist/TxPubSub.d.ts +585 -0
  76. package/dist/TxPubSub.d.ts.map +1 -0
  77. package/dist/TxPubSub.js +521 -0
  78. package/dist/TxPubSub.js.map +1 -0
  79. package/dist/TxQueue.d.ts +32 -32
  80. package/dist/TxQueue.d.ts.map +1 -1
  81. package/dist/TxQueue.js +26 -26
  82. package/dist/TxQueue.js.map +1 -1
  83. package/dist/TxReentrantLock.d.ts +523 -0
  84. package/dist/TxReentrantLock.d.ts.map +1 -0
  85. package/dist/TxReentrantLock.js +504 -0
  86. package/dist/TxReentrantLock.js.map +1 -0
  87. package/dist/TxRef.d.ts +34 -34
  88. package/dist/TxRef.d.ts.map +1 -1
  89. package/dist/TxRef.js +21 -14
  90. package/dist/TxRef.js.map +1 -1
  91. package/dist/TxSemaphore.d.ts +8 -8
  92. package/dist/TxSemaphore.d.ts.map +1 -1
  93. package/dist/TxSemaphore.js +7 -7
  94. package/dist/TxSemaphore.js.map +1 -1
  95. package/dist/TxSubscriptionRef.d.ts +508 -0
  96. package/dist/TxSubscriptionRef.d.ts.map +1 -0
  97. package/dist/TxSubscriptionRef.js +293 -0
  98. package/dist/TxSubscriptionRef.js.map +1 -0
  99. package/dist/index.d.ts +40 -0
  100. package/dist/index.d.ts.map +1 -1
  101. package/dist/index.js +40 -0
  102. package/dist/index.js.map +1 -1
  103. package/dist/internal/effect.js +99 -42
  104. package/dist/internal/effect.js.map +1 -1
  105. package/dist/internal/hashMap.js +3 -2
  106. package/dist/internal/hashMap.js.map +1 -1
  107. package/dist/internal/trie.js +5 -4
  108. package/dist/internal/trie.js.map +1 -1
  109. package/dist/unstable/ai/Tool.d.ts.map +1 -1
  110. package/dist/unstable/ai/Tool.js +0 -9
  111. package/dist/unstable/ai/Tool.js.map +1 -1
  112. package/dist/unstable/cli/Command.d.ts +1 -1
  113. package/dist/unstable/cli/Command.d.ts.map +1 -1
  114. package/dist/unstable/cli/Command.js +1 -1
  115. package/dist/unstable/cli/Command.js.map +1 -1
  116. package/dist/unstable/cluster/K8sHttpClient.js +4 -4
  117. package/dist/unstable/cluster/K8sHttpClient.js.map +1 -1
  118. package/dist/unstable/cluster/Sharding.js +1 -1
  119. package/dist/unstable/cluster/Sharding.js.map +1 -1
  120. package/dist/unstable/encoding/Sse.js +1 -1
  121. package/dist/unstable/encoding/Sse.js.map +1 -1
  122. package/dist/unstable/rpc/RpcServer.d.ts.map +1 -1
  123. package/dist/unstable/rpc/RpcServer.js +1 -2
  124. package/dist/unstable/rpc/RpcServer.js.map +1 -1
  125. package/dist/unstable/socket/Socket.d.ts.map +1 -1
  126. package/dist/unstable/socket/Socket.js +3 -3
  127. package/dist/unstable/socket/Socket.js.map +1 -1
  128. package/package.json +1 -1
  129. package/src/Array.ts +190 -342
  130. package/src/Cache.ts +6 -5
  131. package/src/Channel.ts +506 -102
  132. package/src/Chunk.ts +81 -268
  133. package/src/Effect.ts +437 -518
  134. package/src/Filter.ts +0 -57
  135. package/src/HashMap.ts +15 -14
  136. package/src/Iterable.ts +105 -50
  137. package/src/Option.ts +30 -20
  138. package/src/Pull.ts +1 -1
  139. package/src/Record.ts +43 -152
  140. package/src/Sink.ts +75 -23
  141. package/src/Stream.ts +442 -502
  142. package/src/Trie.ts +18 -17
  143. package/src/TxChunk.ts +72 -53
  144. package/src/TxDeferred.ts +394 -0
  145. package/src/TxHashMap.ts +332 -285
  146. package/src/TxHashSet.ts +111 -116
  147. package/src/TxPriorityQueue.ts +767 -0
  148. package/src/TxPubSub.ts +789 -0
  149. package/src/TxQueue.ts +241 -251
  150. package/src/TxReentrantLock.ts +753 -0
  151. package/src/TxRef.ts +50 -38
  152. package/src/TxSemaphore.ts +29 -32
  153. package/src/TxSubscriptionRef.ts +639 -0
  154. package/src/index.ts +45 -0
  155. package/src/internal/effect.ts +368 -163
  156. package/src/internal/hashMap.ts +7 -5
  157. package/src/internal/trie.ts +16 -9
  158. package/src/unstable/ai/Tool.ts +0 -9
  159. package/src/unstable/cli/Command.ts +6 -4
  160. package/src/unstable/cluster/K8sHttpClient.ts +4 -4
  161. package/src/unstable/cluster/Sharding.ts +1 -1
  162. package/src/unstable/encoding/Sse.ts +1 -1
  163. package/src/unstable/rpc/RpcServer.ts +1 -7
  164. package/src/unstable/socket/Socket.ts +9 -11
@@ -0,0 +1,523 @@
1
+ /**
2
+ * TxReentrantLock is a transactional read/write lock with reentrant semantics using Software
3
+ * Transactional Memory (STM). Multiple readers can hold the lock concurrently, OR a single
4
+ * writer can hold exclusive access. A fiber holding a write lock may acquire additional
5
+ * read or write locks (reentrancy).
6
+ *
7
+ * @since 4.0.0
8
+ */
9
+ import * as Effect from "./Effect.ts";
10
+ import type { Inspectable } from "./Inspectable.ts";
11
+ import type { Pipeable } from "./Pipeable.ts";
12
+ import type * as Scope from "./Scope.ts";
13
+ declare const TypeId = "~effect/transactions/TxReentrantLock";
14
+ /**
15
+ * A TxReentrantLock provides a transactional read/write lock with reentrant semantics.
16
+ * Multiple readers can hold the lock concurrently, or a single writer can hold exclusive
17
+ * access. A fiber holding the write lock may acquire additional read/write locks (reentrancy).
18
+ *
19
+ * @example
20
+ * ```ts
21
+ * import { Effect, TxReentrantLock } from "effect"
22
+ *
23
+ * const program = Effect.gen(function*() {
24
+ * const lock = yield* TxReentrantLock.make()
25
+ *
26
+ * // Multiple readers can proceed concurrently
27
+ * yield* TxReentrantLock.withReadLock(lock, Effect.succeed("reading"))
28
+ *
29
+ * // Writer gets exclusive access
30
+ * yield* TxReentrantLock.withWriteLock(lock, Effect.succeed("writing"))
31
+ * })
32
+ * ```
33
+ *
34
+ * @since 4.0.0
35
+ * @category models
36
+ */
37
+ export interface TxReentrantLock extends Inspectable, Pipeable {
38
+ readonly [TypeId]: typeof TypeId;
39
+ }
40
+ /**
41
+ * Creates a new TxReentrantLock.
42
+ *
43
+ * @example
44
+ * ```ts
45
+ * import { Effect, TxReentrantLock } from "effect"
46
+ *
47
+ * const program = Effect.gen(function*() {
48
+ * const lock = yield* TxReentrantLock.make()
49
+ * const isLocked = yield* TxReentrantLock.locked(lock)
50
+ * console.log(isLocked) // false
51
+ * })
52
+ * ```
53
+ *
54
+ * @since 4.0.0
55
+ * @category constructors
56
+ */
57
+ export declare const make: () => Effect.Effect<TxReentrantLock, never, Effect.Transaction>;
58
+ /**
59
+ * Acquires a read lock. Blocks if another fiber holds the write lock.
60
+ * If the current fiber already holds the write lock, the read lock is granted (reentrancy).
61
+ * Returns the current number of read locks held by this fiber.
62
+ *
63
+ * @example
64
+ * ```ts
65
+ * import { Effect, TxReentrantLock } from "effect"
66
+ *
67
+ * const program = Effect.gen(function*() {
68
+ * const lock = yield* TxReentrantLock.make()
69
+ * const count = yield* TxReentrantLock.acquireRead(lock)
70
+ * console.log(count) // 1
71
+ * yield* TxReentrantLock.releaseRead(lock)
72
+ * })
73
+ * ```
74
+ *
75
+ * @since 4.0.0
76
+ * @category mutations
77
+ */
78
+ export declare const acquireRead: (self: TxReentrantLock) => Effect.Effect<number, never, Effect.Transaction>;
79
+ /**
80
+ * Acquires a write lock. Blocks if any other fiber holds any lock.
81
+ * If the current fiber already holds the write lock, the count is incremented (reentrancy).
82
+ * If the current fiber holds a read lock, the write lock is granted (upgrade).
83
+ * Returns the current number of write locks held by this fiber.
84
+ *
85
+ * @example
86
+ * ```ts
87
+ * import { Effect, TxReentrantLock } from "effect"
88
+ *
89
+ * const program = Effect.gen(function*() {
90
+ * const lock = yield* TxReentrantLock.make()
91
+ * const count = yield* TxReentrantLock.acquireWrite(lock)
92
+ * console.log(count) // 1
93
+ * yield* TxReentrantLock.releaseWrite(lock)
94
+ * })
95
+ * ```
96
+ *
97
+ * @since 4.0.0
98
+ * @category mutations
99
+ */
100
+ export declare const acquireWrite: (self: TxReentrantLock) => Effect.Effect<number, never, Effect.Transaction>;
101
+ /**
102
+ * Releases a read lock held by the current fiber.
103
+ * Returns the remaining number of read locks held by this fiber.
104
+ *
105
+ * @example
106
+ * ```ts
107
+ * import { Effect, TxReentrantLock } from "effect"
108
+ *
109
+ * const program = Effect.gen(function*() {
110
+ * const lock = yield* TxReentrantLock.make()
111
+ * yield* TxReentrantLock.acquireRead(lock)
112
+ * const remaining = yield* TxReentrantLock.releaseRead(lock)
113
+ * console.log(remaining) // 0
114
+ * })
115
+ * ```
116
+ *
117
+ * @since 4.0.0
118
+ * @category mutations
119
+ */
120
+ export declare const releaseRead: (self: TxReentrantLock) => Effect.Effect<number, never, Effect.Transaction>;
121
+ /**
122
+ * Releases a write lock held by the current fiber.
123
+ * Returns the remaining number of write locks held by this fiber.
124
+ *
125
+ * @example
126
+ * ```ts
127
+ * import { Effect, TxReentrantLock } from "effect"
128
+ *
129
+ * const program = Effect.gen(function*() {
130
+ * const lock = yield* TxReentrantLock.make()
131
+ * yield* TxReentrantLock.acquireWrite(lock)
132
+ * const remaining = yield* TxReentrantLock.releaseWrite(lock)
133
+ * console.log(remaining) // 0
134
+ * })
135
+ * ```
136
+ *
137
+ * @since 4.0.0
138
+ * @category mutations
139
+ */
140
+ export declare const releaseWrite: (self: TxReentrantLock) => Effect.Effect<number, never, Effect.Transaction>;
141
+ /**
142
+ * Acquires a read lock for the duration of the scope.
143
+ * The lock is automatically released when the scope closes.
144
+ *
145
+ * @example
146
+ * ```ts
147
+ * import { Effect, TxReentrantLock } from "effect"
148
+ *
149
+ * const program = Effect.gen(function*() {
150
+ * const lock = yield* TxReentrantLock.make()
151
+ *
152
+ * yield* Effect.scoped(
153
+ * Effect.gen(function*() {
154
+ * yield* TxReentrantLock.readLock(lock)
155
+ * // read lock is held for the duration of the scope
156
+ * })
157
+ * )
158
+ * // read lock is released
159
+ * })
160
+ * ```
161
+ *
162
+ * @since 4.0.0
163
+ * @category mutations
164
+ */
165
+ export declare const readLock: (self: TxReentrantLock) => Effect.Effect<number, never, Scope.Scope>;
166
+ /**
167
+ * Acquires a write lock for the duration of the scope.
168
+ * The lock is automatically released when the scope closes.
169
+ *
170
+ * @example
171
+ * ```ts
172
+ * import { Effect, TxReentrantLock } from "effect"
173
+ *
174
+ * const program = Effect.gen(function*() {
175
+ * const lock = yield* TxReentrantLock.make()
176
+ *
177
+ * yield* Effect.scoped(
178
+ * Effect.gen(function*() {
179
+ * yield* TxReentrantLock.writeLock(lock)
180
+ * // write lock is held for the duration of the scope
181
+ * })
182
+ * )
183
+ * // write lock is released
184
+ * })
185
+ * ```
186
+ *
187
+ * @since 4.0.0
188
+ * @category mutations
189
+ */
190
+ export declare const writeLock: (self: TxReentrantLock) => Effect.Effect<number, never, Scope.Scope>;
191
+ /**
192
+ * Alias for `writeLock`. Acquires a write lock for the duration of the scope.
193
+ *
194
+ * @example
195
+ * ```ts
196
+ * import { Effect, TxReentrantLock } from "effect"
197
+ *
198
+ * const program = Effect.gen(function*() {
199
+ * const lock = yield* TxReentrantLock.make()
200
+ *
201
+ * yield* Effect.scoped(
202
+ * Effect.gen(function*() {
203
+ * yield* TxReentrantLock.lock(lock)
204
+ * // exclusive lock is held
205
+ * })
206
+ * )
207
+ * })
208
+ * ```
209
+ *
210
+ * @since 4.0.0
211
+ * @category mutations
212
+ */
213
+ export declare const lock: (self: TxReentrantLock) => Effect.Effect<number, never, Scope.Scope>;
214
+ /**
215
+ * Runs the provided effect while holding a read lock. The lock is automatically
216
+ * released after the effect completes, fails, or is interrupted.
217
+ *
218
+ * @example
219
+ * ```ts
220
+ * import { Effect, TxReentrantLock } from "effect"
221
+ *
222
+ * const program = Effect.gen(function*() {
223
+ * const lock = yield* TxReentrantLock.make()
224
+ * const result = yield* TxReentrantLock.withReadLock(
225
+ * lock,
226
+ * Effect.succeed("read data")
227
+ * )
228
+ * console.log(result) // "read data"
229
+ * })
230
+ * ```
231
+ *
232
+ * @since 4.0.0
233
+ * @category mutations
234
+ */
235
+ export declare const withReadLock: {
236
+ /**
237
+ * Runs the provided effect while holding a read lock. The lock is automatically
238
+ * released after the effect completes, fails, or is interrupted.
239
+ *
240
+ * @example
241
+ * ```ts
242
+ * import { Effect, TxReentrantLock } from "effect"
243
+ *
244
+ * const program = Effect.gen(function*() {
245
+ * const lock = yield* TxReentrantLock.make()
246
+ * const result = yield* TxReentrantLock.withReadLock(
247
+ * lock,
248
+ * Effect.succeed("read data")
249
+ * )
250
+ * console.log(result) // "read data"
251
+ * })
252
+ * ```
253
+ *
254
+ * @since 4.0.0
255
+ * @category mutations
256
+ */
257
+ <A, E, R>(effect: Effect.Effect<A, E, R>): (self: TxReentrantLock) => Effect.Effect<A, E, R>;
258
+ /**
259
+ * Runs the provided effect while holding a read lock. The lock is automatically
260
+ * released after the effect completes, fails, or is interrupted.
261
+ *
262
+ * @example
263
+ * ```ts
264
+ * import { Effect, TxReentrantLock } from "effect"
265
+ *
266
+ * const program = Effect.gen(function*() {
267
+ * const lock = yield* TxReentrantLock.make()
268
+ * const result = yield* TxReentrantLock.withReadLock(
269
+ * lock,
270
+ * Effect.succeed("read data")
271
+ * )
272
+ * console.log(result) // "read data"
273
+ * })
274
+ * ```
275
+ *
276
+ * @since 4.0.0
277
+ * @category mutations
278
+ */
279
+ <A, E, R>(self: TxReentrantLock, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
280
+ };
281
+ /**
282
+ * Runs the provided effect while holding a write lock. The lock is automatically
283
+ * released after the effect completes, fails, or is interrupted.
284
+ *
285
+ * @example
286
+ * ```ts
287
+ * import { Effect, TxReentrantLock } from "effect"
288
+ *
289
+ * const program = Effect.gen(function*() {
290
+ * const lock = yield* TxReentrantLock.make()
291
+ * const result = yield* TxReentrantLock.withWriteLock(
292
+ * lock,
293
+ * Effect.succeed("wrote data")
294
+ * )
295
+ * console.log(result) // "wrote data"
296
+ * })
297
+ * ```
298
+ *
299
+ * @since 4.0.0
300
+ * @category mutations
301
+ */
302
+ export declare const withWriteLock: {
303
+ /**
304
+ * Runs the provided effect while holding a write lock. The lock is automatically
305
+ * released after the effect completes, fails, or is interrupted.
306
+ *
307
+ * @example
308
+ * ```ts
309
+ * import { Effect, TxReentrantLock } from "effect"
310
+ *
311
+ * const program = Effect.gen(function*() {
312
+ * const lock = yield* TxReentrantLock.make()
313
+ * const result = yield* TxReentrantLock.withWriteLock(
314
+ * lock,
315
+ * Effect.succeed("wrote data")
316
+ * )
317
+ * console.log(result) // "wrote data"
318
+ * })
319
+ * ```
320
+ *
321
+ * @since 4.0.0
322
+ * @category mutations
323
+ */
324
+ <A, E, R>(effect: Effect.Effect<A, E, R>): (self: TxReentrantLock) => Effect.Effect<A, E, R>;
325
+ /**
326
+ * Runs the provided effect while holding a write lock. The lock is automatically
327
+ * released after the effect completes, fails, or is interrupted.
328
+ *
329
+ * @example
330
+ * ```ts
331
+ * import { Effect, TxReentrantLock } from "effect"
332
+ *
333
+ * const program = Effect.gen(function*() {
334
+ * const lock = yield* TxReentrantLock.make()
335
+ * const result = yield* TxReentrantLock.withWriteLock(
336
+ * lock,
337
+ * Effect.succeed("wrote data")
338
+ * )
339
+ * console.log(result) // "wrote data"
340
+ * })
341
+ * ```
342
+ *
343
+ * @since 4.0.0
344
+ * @category mutations
345
+ */
346
+ <A, E, R>(self: TxReentrantLock, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
347
+ };
348
+ /**
349
+ * Alias for `withWriteLock`. Runs the provided effect while holding a write lock.
350
+ *
351
+ * @example
352
+ * ```ts
353
+ * import { Effect, TxReentrantLock } from "effect"
354
+ *
355
+ * const program = Effect.gen(function*() {
356
+ * const lock = yield* TxReentrantLock.make()
357
+ * const result = yield* TxReentrantLock.withLock(
358
+ * lock,
359
+ * Effect.succeed("exclusive operation")
360
+ * )
361
+ * console.log(result) // "exclusive operation"
362
+ * })
363
+ * ```
364
+ *
365
+ * @since 4.0.0
366
+ * @category mutations
367
+ */
368
+ export declare const withLock: {
369
+ /**
370
+ * Alias for `withWriteLock`. Runs the provided effect while holding a write lock.
371
+ *
372
+ * @example
373
+ * ```ts
374
+ * import { Effect, TxReentrantLock } from "effect"
375
+ *
376
+ * const program = Effect.gen(function*() {
377
+ * const lock = yield* TxReentrantLock.make()
378
+ * const result = yield* TxReentrantLock.withLock(
379
+ * lock,
380
+ * Effect.succeed("exclusive operation")
381
+ * )
382
+ * console.log(result) // "exclusive operation"
383
+ * })
384
+ * ```
385
+ *
386
+ * @since 4.0.0
387
+ * @category mutations
388
+ */
389
+ <A, E, R>(effect: Effect.Effect<A, E, R>): (self: TxReentrantLock) => Effect.Effect<A, E, R>;
390
+ /**
391
+ * Alias for `withWriteLock`. Runs the provided effect while holding a write lock.
392
+ *
393
+ * @example
394
+ * ```ts
395
+ * import { Effect, TxReentrantLock } from "effect"
396
+ *
397
+ * const program = Effect.gen(function*() {
398
+ * const lock = yield* TxReentrantLock.make()
399
+ * const result = yield* TxReentrantLock.withLock(
400
+ * lock,
401
+ * Effect.succeed("exclusive operation")
402
+ * )
403
+ * console.log(result) // "exclusive operation"
404
+ * })
405
+ * ```
406
+ *
407
+ * @since 4.0.0
408
+ * @category mutations
409
+ */
410
+ <A, E, R>(self: TxReentrantLock, effect: Effect.Effect<A, E, R>): Effect.Effect<A, E, R>;
411
+ };
412
+ /**
413
+ * Returns the total number of read locks held across all fibers.
414
+ *
415
+ * @example
416
+ * ```ts
417
+ * import { Effect, TxReentrantLock } from "effect"
418
+ *
419
+ * const program = Effect.gen(function*() {
420
+ * const lock = yield* TxReentrantLock.make()
421
+ * yield* TxReentrantLock.acquireRead(lock)
422
+ * const count = yield* TxReentrantLock.readLocks(lock)
423
+ * console.log(count) // 1
424
+ * yield* TxReentrantLock.releaseRead(lock)
425
+ * })
426
+ * ```
427
+ *
428
+ * @since 4.0.0
429
+ * @category getters
430
+ */
431
+ export declare const readLocks: (self: TxReentrantLock) => Effect.Effect<number, never, Effect.Transaction>;
432
+ /**
433
+ * Returns the number of write locks held (0 or the reentrant count).
434
+ *
435
+ * @example
436
+ * ```ts
437
+ * import { Effect, TxReentrantLock } from "effect"
438
+ *
439
+ * const program = Effect.gen(function*() {
440
+ * const lock = yield* TxReentrantLock.make()
441
+ * const count = yield* TxReentrantLock.writeLocks(lock)
442
+ * console.log(count) // 0
443
+ * })
444
+ * ```
445
+ *
446
+ * @since 4.0.0
447
+ * @category getters
448
+ */
449
+ export declare const writeLocks: (self: TxReentrantLock) => Effect.Effect<number, never, Effect.Transaction>;
450
+ /**
451
+ * Checks if the lock is held by any fiber (read or write).
452
+ *
453
+ * @example
454
+ * ```ts
455
+ * import { Effect, TxReentrantLock } from "effect"
456
+ *
457
+ * const program = Effect.gen(function*() {
458
+ * const lock = yield* TxReentrantLock.make()
459
+ * const isLocked = yield* TxReentrantLock.locked(lock)
460
+ * console.log(isLocked) // false
461
+ * })
462
+ * ```
463
+ *
464
+ * @since 4.0.0
465
+ * @category getters
466
+ */
467
+ export declare const locked: (self: TxReentrantLock) => Effect.Effect<boolean, never, Effect.Transaction>;
468
+ /**
469
+ * Checks if any fiber holds a read lock.
470
+ *
471
+ * @example
472
+ * ```ts
473
+ * import { Effect, TxReentrantLock } from "effect"
474
+ *
475
+ * const program = Effect.gen(function*() {
476
+ * const lock = yield* TxReentrantLock.make()
477
+ * const isReadLocked = yield* TxReentrantLock.readLocked(lock)
478
+ * console.log(isReadLocked) // false
479
+ * })
480
+ * ```
481
+ *
482
+ * @since 4.0.0
483
+ * @category getters
484
+ */
485
+ export declare const readLocked: (self: TxReentrantLock) => Effect.Effect<boolean, never, Effect.Transaction>;
486
+ /**
487
+ * Checks if any fiber holds a write lock.
488
+ *
489
+ * @example
490
+ * ```ts
491
+ * import { Effect, TxReentrantLock } from "effect"
492
+ *
493
+ * const program = Effect.gen(function*() {
494
+ * const lock = yield* TxReentrantLock.make()
495
+ * const isWriteLocked = yield* TxReentrantLock.writeLocked(lock)
496
+ * console.log(isWriteLocked) // false
497
+ * })
498
+ * ```
499
+ *
500
+ * @since 4.0.0
501
+ * @category getters
502
+ */
503
+ export declare const writeLocked: (self: TxReentrantLock) => Effect.Effect<boolean, never, Effect.Transaction>;
504
+ /**
505
+ * Checks if the given value is a TxReentrantLock.
506
+ *
507
+ * @example
508
+ * ```ts
509
+ * import { TxReentrantLock } from "effect"
510
+ *
511
+ * declare const someValue: unknown
512
+ *
513
+ * if (TxReentrantLock.isTxReentrantLock(someValue)) {
514
+ * console.log("This is a TxReentrantLock")
515
+ * }
516
+ * ```
517
+ *
518
+ * @since 4.0.0
519
+ * @category guards
520
+ */
521
+ export declare const isTxReentrantLock: (u: unknown) => u is TxReentrantLock;
522
+ export {};
523
+ //# sourceMappingURL=TxReentrantLock.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TxReentrantLock.d.ts","sourceRoot":"","sources":["../src/TxReentrantLock.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;A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