@fncts/io 0.0.45 → 0.0.46

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 (558) hide show
  1. package/Cached.d.ts +2 -2
  2. package/Channel/ChildExecutorDecision.d.ts +1 -1
  3. package/Channel/UpstreamPullRequest.d.ts +1 -1
  4. package/Channel.d.ts +2 -2
  5. package/Clock.d.ts +2 -2
  6. package/Console.d.ts +2 -2
  7. package/Fiber.d.ts +19 -19
  8. package/FiberRef.d.ts +5 -5
  9. package/FiberRefs.d.ts +1 -1
  10. package/FiberScope.d.ts +1 -1
  11. package/FiberStatus.d.ts +1 -1
  12. package/Future/api.d.ts +6 -0
  13. package/Future.d.ts +2 -2
  14. package/Hub.d.ts +1 -1
  15. package/IO/runtime.d.ts +3 -3
  16. package/IO.d.ts +63 -63
  17. package/IOEnv.d.ts +2 -2
  18. package/InterruptStatus.d.ts +1 -1
  19. package/Layer.d.ts +1 -1
  20. package/Logger.d.ts +2 -2
  21. package/MVar.d.ts +1 -1
  22. package/Push.d.ts +2 -2
  23. package/Queue/api.d.ts +7 -7
  24. package/Queue.d.ts +4 -4
  25. package/Random.d.ts +2 -2
  26. package/Ref/Synchronized.d.ts +2 -2
  27. package/Ref/api.d.ts +7 -7
  28. package/Ref.d.ts +7 -7
  29. package/RefSubject.d.ts +1 -1
  30. package/Reloadable.d.ts +2 -2
  31. package/RuntimeFlags.d.ts +1 -1
  32. package/STM.d.ts +4 -4
  33. package/Schedule.d.ts +2 -2
  34. package/Scope/ReleaseMap.d.ts +2 -2
  35. package/Scope.d.ts +1 -1
  36. package/ScopedRef.d.ts +1 -1
  37. package/Semaphore.d.ts +18 -8
  38. package/Sink.d.ts +1 -1
  39. package/State.d.ts +1 -1
  40. package/Stream.d.ts +1 -1
  41. package/Subject.d.ts +1 -1
  42. package/Supervisor.d.ts +2 -2
  43. package/TExit.d.ts +1 -1
  44. package/TFuture.d.ts +2 -2
  45. package/TReentrantLock.d.ts +1 -1
  46. package/TRef.d.ts +2 -2
  47. package/TSemaphore.d.ts +2 -2
  48. package/_cjs/Cached/api.cjs +9 -9
  49. package/_cjs/Cached/internal.cjs +1 -1
  50. package/_cjs/Cached.cjs +8 -8
  51. package/_cjs/Cached.cjs.map +1 -1
  52. package/_cjs/Channel/ChildExecutorDecision.cjs +8 -8
  53. package/_cjs/Channel/ChildExecutorDecision.cjs.map +1 -1
  54. package/_cjs/Channel/UpstreamPullRequest.cjs +8 -8
  55. package/_cjs/Channel/UpstreamPullRequest.cjs.map +1 -1
  56. package/_cjs/Channel/api/interruptWhen.cjs +5 -5
  57. package/_cjs/Channel/api/mapOutConcurrentIO.cjs +19 -19
  58. package/_cjs/Channel/api/mergeAll.cjs +1 -1
  59. package/_cjs/Channel/api/mergeAllUnboundedWith.cjs +1 -1
  60. package/_cjs/Channel/api/mergeAllWith.cjs +26 -26
  61. package/_cjs/Channel/api/mergeMap.cjs +2 -2
  62. package/_cjs/Channel/api/mergeWith.cjs +14 -14
  63. package/_cjs/Channel/api/run.cjs +2 -2
  64. package/_cjs/Channel/api/runCollect.cjs +2 -2
  65. package/_cjs/Channel/api/runDrain.cjs +2 -2
  66. package/_cjs/Channel/api/runScoped.cjs +10 -10
  67. package/_cjs/Channel/api/toPull.cjs +4 -4
  68. package/_cjs/Channel/api/zipConcurrent.cjs +5 -5
  69. package/_cjs/Channel/api.cjs +26 -26
  70. package/_cjs/Channel/internal/ChannelExecutor.cjs +25 -25
  71. package/_cjs/Channel/internal/ChannelExecutor.cjs.map +1 -1
  72. package/_cjs/Channel/internal/ChannelState.cjs +1 -1
  73. package/_cjs/Channel/internal/SingleProducerAsyncInput.cjs +13 -13
  74. package/_cjs/Channel.cjs +8 -8
  75. package/_cjs/Channel.cjs.map +1 -1
  76. package/_cjs/Clock/api.cjs +1 -1
  77. package/_cjs/Clock/definition.cjs +1 -1
  78. package/_cjs/Clock/live.cjs +4 -4
  79. package/_cjs/Clock.cjs +8 -8
  80. package/_cjs/Clock.cjs.map +1 -1
  81. package/_cjs/Console/api.cjs +1 -1
  82. package/_cjs/Console/definition.cjs +1 -1
  83. package/_cjs/Console/live.cjs +1 -1
  84. package/_cjs/Console.cjs +8 -8
  85. package/_cjs/Console.cjs.map +1 -1
  86. package/_cjs/CountdownLatch.cjs +6 -6
  87. package/_cjs/Differ/api.cjs +3 -3
  88. package/_cjs/Fiber/FiberRuntime.cjs +30 -30
  89. package/_cjs/Fiber/api/awaitAll.cjs +3 -3
  90. package/_cjs/Fiber/api/collectAll.cjs +18 -18
  91. package/_cjs/Fiber/api/fromIO.cjs +2 -2
  92. package/_cjs/Fiber/api/interrupt.cjs +2 -2
  93. package/_cjs/Fiber/api/interruptAll.cjs +3 -3
  94. package/_cjs/Fiber/api/interruptAs.cjs +2 -2
  95. package/_cjs/Fiber/api/interruptFork.cjs +2 -2
  96. package/_cjs/Fiber/api/join.cjs +2 -2
  97. package/_cjs/Fiber/api/joinAll.cjs +3 -3
  98. package/_cjs/Fiber/api/mapFiber.cjs +4 -4
  99. package/_cjs/Fiber/api/mapIO.cjs +10 -10
  100. package/_cjs/Fiber/api/zipWith.cjs +12 -12
  101. package/_cjs/Fiber/constructors.cjs +5 -5
  102. package/_cjs/Fiber/definition.cjs +1 -1
  103. package/_cjs/Fiber.cjs +83 -83
  104. package/_cjs/Fiber.cjs.map +1 -1
  105. package/_cjs/FiberRef/api/locallyScoped.cjs +3 -3
  106. package/_cjs/FiberRef/api/locallyScopedWith.cjs +2 -2
  107. package/_cjs/FiberRef/constructors.cjs +4 -4
  108. package/_cjs/FiberRef/definition.cjs +4 -4
  109. package/_cjs/FiberRef/operations.cjs +3 -3
  110. package/_cjs/FiberRef/unsafe.cjs +16 -16
  111. package/_cjs/FiberRef/unsafe.cjs.map +1 -1
  112. package/_cjs/FiberRef.cjs +24 -24
  113. package/_cjs/FiberRef.cjs.map +1 -1
  114. package/_cjs/FiberRefs/Patch.cjs +6 -6
  115. package/_cjs/FiberRefs/api.cjs +8 -8
  116. package/_cjs/FiberRefs/definition.cjs +1 -1
  117. package/_cjs/FiberRefs.cjs +8 -8
  118. package/_cjs/FiberRefs.cjs.map +1 -1
  119. package/_cjs/FiberScope/definition.cjs +5 -5
  120. package/_cjs/FiberScope.cjs +8 -8
  121. package/_cjs/FiberScope.cjs.map +1 -1
  122. package/_cjs/FiberSet.cjs +9 -9
  123. package/_cjs/FiberStatus/definition.cjs +1 -1
  124. package/_cjs/FiberStatus.cjs +8 -8
  125. package/_cjs/FiberStatus.cjs.map +1 -1
  126. package/_cjs/Future/api.cjs +18 -9
  127. package/_cjs/Future/api.cjs.map +1 -1
  128. package/_cjs/Future/constructors.cjs +2 -2
  129. package/_cjs/Future.cjs +8 -8
  130. package/_cjs/Future.cjs.map +1 -1
  131. package/_cjs/Hub/api.cjs +10 -10
  132. package/_cjs/Hub/internal.cjs +15 -15
  133. package/_cjs/Hub.cjs +8 -8
  134. package/_cjs/Hub.cjs.map +1 -1
  135. package/_cjs/IO/api/acquireRelease.cjs +1 -1
  136. package/_cjs/IO/api/acquireReleaseExit.cjs +3 -3
  137. package/_cjs/IO/api/acquireReleaseInterruptible.cjs +1 -1
  138. package/_cjs/IO/api/acquireReleaseInterruptibleExit.cjs +3 -3
  139. package/_cjs/IO/api/addFinalizer.cjs +1 -1
  140. package/_cjs/IO/api/addFinalizerExit.cjs +4 -4
  141. package/_cjs/IO/api/all.cjs +4 -4
  142. package/_cjs/IO/api/asyncIO.cjs +7 -7
  143. package/_cjs/IO/api/asyncInterrupt.cjs +6 -6
  144. package/_cjs/IO/api/blocking.cjs +3 -3
  145. package/_cjs/IO/api/bracket.cjs +1 -1
  146. package/_cjs/IO/api/bracketExit.cjs +4 -4
  147. package/_cjs/IO/api/clockWith.cjs +5 -5
  148. package/_cjs/IO/api/concurrency.cjs +6 -6
  149. package/_cjs/IO/api/concurrency.cjs.map +1 -1
  150. package/_cjs/IO/api/concurrentFinalizers.cjs +8 -8
  151. package/_cjs/IO/api/consoleWith.cjs +5 -5
  152. package/_cjs/IO/api/daemonChildren.cjs +4 -4
  153. package/_cjs/IO/api/delay.cjs +2 -2
  154. package/_cjs/IO/api/descriptor.cjs +4 -4
  155. package/_cjs/IO/api/diffFiberRefs.cjs +2 -2
  156. package/_cjs/IO/api/disconnect.cjs +4 -4
  157. package/_cjs/IO/api/ensuringChildren.cjs +4 -4
  158. package/_cjs/IO/api/environment.cjs +4 -4
  159. package/_cjs/IO/api/foreachConcurrent.cjs +21 -21
  160. package/_cjs/IO/api/foreachExec.cjs +4 -4
  161. package/_cjs/IO/api/fork.cjs +7 -7
  162. package/_cjs/IO/api/forkAll.cjs +3 -3
  163. package/_cjs/IO/api/forkDaemon.cjs +2 -2
  164. package/_cjs/IO/api/forkIn.cjs +5 -5
  165. package/_cjs/IO/api/forkScoped.cjs +5 -5
  166. package/_cjs/IO/api/fulfill.cjs +3 -3
  167. package/_cjs/IO/api/interrupt.cjs +6 -6
  168. package/_cjs/IO/api/memoize.cjs +7 -7
  169. package/_cjs/IO/api/onTermination.cjs +4 -4
  170. package/_cjs/IO/api/once.cjs +3 -3
  171. package/_cjs/IO/api/patchFiberRefs.cjs +2 -2
  172. package/_cjs/IO/api/provideLayer.cjs +5 -5
  173. package/_cjs/IO/api/provideScope.cjs +2 -2
  174. package/_cjs/IO/api/provideSomeLayer.cjs +2 -2
  175. package/_cjs/IO/api/provideSomeRuntime.cjs +6 -6
  176. package/_cjs/IO/api/race.cjs +8 -8
  177. package/_cjs/IO/api/raceFirst.cjs +2 -2
  178. package/_cjs/IO/api/raceWith.cjs +3 -3
  179. package/_cjs/IO/api/randomWith.cjs +5 -5
  180. package/_cjs/IO/api/repeat.cjs +5 -5
  181. package/_cjs/IO/api/retry.cjs +4 -4
  182. package/_cjs/IO/api/schedule.cjs +2 -2
  183. package/_cjs/IO/api/scope.cjs +2 -2
  184. package/_cjs/IO/api/scopeWith.cjs +2 -2
  185. package/_cjs/IO/api/scoped.cjs +2 -2
  186. package/_cjs/IO/api/sequenceT.cjs +1 -1
  187. package/_cjs/IO/api/sleep.cjs +1 -1
  188. package/_cjs/IO/api/stateful.cjs +3 -3
  189. package/_cjs/IO/api/supervised.cjs +3 -3
  190. package/_cjs/IO/api/timeout.cjs +8 -8
  191. package/_cjs/IO/api/transplant.cjs +5 -5
  192. package/_cjs/IO/api/whenFiberRef.cjs +2 -2
  193. package/_cjs/IO/api/whenRef.cjs +2 -2
  194. package/_cjs/IO/api/withChildren.cjs +4 -4
  195. package/_cjs/IO/api/withEarlyRelease.cjs +4 -4
  196. package/_cjs/IO/api/withFinalizer.cjs +1 -1
  197. package/_cjs/IO/api/withFinalizerExit.cjs +1 -1
  198. package/_cjs/IO/api/zipConcurrent.cjs +13 -13
  199. package/_cjs/IO/api.cjs +24 -24
  200. package/_cjs/IO/api.cjs.map +1 -1
  201. package/_cjs/IO/definition.cjs +1 -1
  202. package/_cjs/IO/runtime.cjs +15 -15
  203. package/_cjs/IO.cjs +256 -256
  204. package/_cjs/IO.cjs.map +1 -1
  205. package/_cjs/IOEnv/definition.cjs +8 -8
  206. package/_cjs/IOEnv/definition.cjs.map +1 -1
  207. package/_cjs/IOEnv/live.cjs +8 -8
  208. package/_cjs/IOEnv/live.cjs.map +1 -1
  209. package/_cjs/IOEnv/services.cjs +1 -1
  210. package/_cjs/IOEnv.cjs +8 -8
  211. package/_cjs/IOEnv.cjs.map +1 -1
  212. package/_cjs/InterruptStatus.cjs +8 -8
  213. package/_cjs/InterruptStatus.cjs.map +1 -1
  214. package/_cjs/Layer/MemoMap.cjs +21 -21
  215. package/_cjs/Layer/api.cjs +14 -14
  216. package/_cjs/Layer.cjs +8 -8
  217. package/_cjs/Layer.cjs.map +1 -1
  218. package/_cjs/Logger/api.cjs +2 -2
  219. package/_cjs/Logger/constructors.cjs +5 -5
  220. package/_cjs/Logger.cjs +8 -8
  221. package/_cjs/Logger.cjs.map +1 -1
  222. package/_cjs/MVar/api.cjs +11 -11
  223. package/_cjs/MVar.cjs +8 -8
  224. package/_cjs/MVar.cjs.map +1 -1
  225. package/_cjs/Push/api.cjs +33 -33
  226. package/_cjs/Push/internal.cjs +18 -19
  227. package/_cjs/Push/internal.cjs.map +1 -1
  228. package/_cjs/Push.cjs +8 -8
  229. package/_cjs/Push.cjs.map +1 -1
  230. package/_cjs/Queue/api/dimapIO.cjs +1 -1
  231. package/_cjs/Queue/api/filterInputIO.cjs +3 -3
  232. package/_cjs/Queue/api/filterOutputIO.cjs +3 -3
  233. package/_cjs/Queue/api/poll.cjs +2 -2
  234. package/_cjs/Queue/api/takeBetween.cjs +3 -3
  235. package/_cjs/Queue/api/takeN.cjs +1 -1
  236. package/_cjs/Queue/api/zipWithIO.cjs +4 -4
  237. package/_cjs/Queue/api.cjs +32 -32
  238. package/_cjs/Queue/api.cjs.map +1 -1
  239. package/_cjs/Queue/constructors.cjs +1 -1
  240. package/_cjs/Queue/internal.cjs +9 -9
  241. package/_cjs/Queue/strategy.cjs +6 -6
  242. package/_cjs/Queue.cjs +16 -16
  243. package/_cjs/Queue.cjs.map +1 -1
  244. package/_cjs/Random/api.cjs +1 -1
  245. package/_cjs/Random/definition.cjs +1 -1
  246. package/_cjs/Random/live.cjs +2 -2
  247. package/_cjs/Random/live.cjs.map +1 -1
  248. package/_cjs/Random.cjs +8 -8
  249. package/_cjs/Random.cjs.map +1 -1
  250. package/_cjs/Ref/Atomic.cjs +1 -1
  251. package/_cjs/Ref/Derived.cjs +4 -4
  252. package/_cjs/Ref/DerivedAll.cjs +4 -4
  253. package/_cjs/Ref/Synchronized/api.cjs +3 -3
  254. package/_cjs/Ref/Synchronized/constructors.cjs +5 -5
  255. package/_cjs/Ref/Synchronized/definition.cjs +1 -1
  256. package/_cjs/Ref/Synchronized.cjs +8 -8
  257. package/_cjs/Ref/Synchronized.cjs.map +1 -1
  258. package/_cjs/Ref/api/collect.cjs +3 -3
  259. package/_cjs/Ref/api/dimap.cjs +2 -2
  260. package/_cjs/Ref/api/filter.cjs +3 -3
  261. package/_cjs/Ref/api/modify.cjs +1 -1
  262. package/_cjs/Ref/api.cjs +35 -36
  263. package/_cjs/Ref/api.cjs.map +1 -1
  264. package/_cjs/Ref/constructors.cjs +1 -1
  265. package/_cjs/Ref.cjs +35 -35
  266. package/_cjs/Ref.cjs.map +1 -1
  267. package/_cjs/RefSubject/Atomic.cjs +5 -5
  268. package/_cjs/RefSubject/Synchronized/api.cjs +4 -4
  269. package/_cjs/RefSubject/Synchronized/definition.cjs +2 -2
  270. package/_cjs/RefSubject/api.cjs +4 -4
  271. package/_cjs/RefSubject.cjs +11 -11
  272. package/_cjs/RefSubject.cjs.map +1 -1
  273. package/_cjs/Reloadable/api.cjs +4 -4
  274. package/_cjs/Reloadable/api.cjs.map +1 -1
  275. package/_cjs/Reloadable/constructors.cjs +10 -10
  276. package/_cjs/Reloadable/definition.cjs +3 -3
  277. package/_cjs/Reloadable.cjs +8 -8
  278. package/_cjs/Reloadable.cjs.map +1 -1
  279. package/_cjs/RuntimeFlags/Patch.cjs +1 -1
  280. package/_cjs/RuntimeFlags/RuntimeFlags.cjs +1 -1
  281. package/_cjs/RuntimeFlags.cjs +8 -8
  282. package/_cjs/RuntimeFlags.cjs.map +1 -1
  283. package/_cjs/STM/api/atomically.cjs +7 -7
  284. package/_cjs/STM/api/core-api.cjs +3 -3
  285. package/_cjs/STM/api.cjs +10 -10
  286. package/_cjs/STM/definition.cjs +1 -1
  287. package/_cjs/STM/driver.cjs +5 -5
  288. package/_cjs/STM/internal/CommitState.cjs +1 -1
  289. package/_cjs/STM/internal/Journal.cjs +4 -4
  290. package/_cjs/STM.cjs +16 -16
  291. package/_cjs/STM.cjs.map +1 -1
  292. package/_cjs/Schedule/Decision.cjs +2 -2
  293. package/_cjs/Schedule/api/driver.cjs +12 -12
  294. package/_cjs/Schedule/api.cjs +20 -20
  295. package/_cjs/Schedule/api.cjs.map +1 -1
  296. package/_cjs/Schedule.cjs +16 -16
  297. package/_cjs/Schedule.cjs.map +1 -1
  298. package/_cjs/Scope/Finalizer/definition.cjs +2 -2
  299. package/_cjs/Scope/ReleaseMap/api/releaseAll.cjs +8 -8
  300. package/_cjs/Scope/ReleaseMap/api.cjs +6 -6
  301. package/_cjs/Scope/ReleaseMap/constructors.cjs +3 -3
  302. package/_cjs/Scope/ReleaseMap/definition.cjs +1 -1
  303. package/_cjs/Scope/ReleaseMap.cjs +8 -8
  304. package/_cjs/Scope/ReleaseMap.cjs.map +1 -1
  305. package/_cjs/Scope/api.cjs +10 -10
  306. package/_cjs/Scope/definition.cjs +2 -2
  307. package/_cjs/Scope.cjs +8 -8
  308. package/_cjs/Scope.cjs.map +1 -1
  309. package/_cjs/ScopedRef/api.cjs +12 -12
  310. package/_cjs/ScopedRef.cjs +8 -8
  311. package/_cjs/ScopedRef.cjs.map +1 -1
  312. package/_cjs/Semaphore.cjs +101 -44
  313. package/_cjs/Semaphore.cjs.map +1 -1
  314. package/_cjs/Sink/api.cjs +34 -34
  315. package/_cjs/Sink/api.cjs.map +1 -1
  316. package/_cjs/Sink.cjs +8 -8
  317. package/_cjs/Sink.cjs.map +1 -1
  318. package/_cjs/State/api.cjs +4 -4
  319. package/_cjs/State.cjs +8 -8
  320. package/_cjs/State.cjs.map +1 -1
  321. package/_cjs/Stream/api/zipAllWith.cjs +8 -8
  322. package/_cjs/Stream/api/zipWith.cjs +1 -1
  323. package/_cjs/Stream/api/zipWithChunks.cjs +6 -6
  324. package/_cjs/Stream/api.cjs +70 -70
  325. package/_cjs/Stream/api.cjs.map +1 -1
  326. package/_cjs/Stream/internal/Handoff.cjs +6 -6
  327. package/_cjs/Stream/internal/Pull.cjs +7 -7
  328. package/_cjs/Stream/internal/Pull.cjs.map +1 -1
  329. package/_cjs/Stream/internal/Take.cjs +11 -11
  330. package/_cjs/Stream/internal/Take.cjs.map +1 -1
  331. package/_cjs/Stream/internal/util.cjs +3 -3
  332. package/_cjs/Stream.cjs +8 -8
  333. package/_cjs/Stream.cjs.map +1 -1
  334. package/_cjs/Subject/Atomic.cjs +1 -1
  335. package/_cjs/Subject/api.cjs +1 -1
  336. package/_cjs/Subject.cjs +11 -11
  337. package/_cjs/Subject.cjs.map +1 -1
  338. package/_cjs/SubscriptionRef.cjs +7 -7
  339. package/_cjs/Supervisor/api.cjs +2 -2
  340. package/_cjs/Supervisor/constructors.cjs +8 -6
  341. package/_cjs/Supervisor/constructors.cjs.map +1 -1
  342. package/_cjs/Supervisor/definition.cjs +1 -1
  343. package/_cjs/Supervisor.cjs +8 -8
  344. package/_cjs/Supervisor.cjs.map +1 -1
  345. package/_cjs/SupervisorPatch.cjs +4 -4
  346. package/_cjs/TExit/definition.cjs +6 -6
  347. package/_cjs/TExit/definition.cjs.map +1 -1
  348. package/_cjs/TExit.cjs +8 -8
  349. package/_cjs/TExit.cjs.map +1 -1
  350. package/_cjs/TFuture/api.cjs +9 -9
  351. package/_cjs/TFuture/constructors.cjs +5 -5
  352. package/_cjs/TFuture/definition.cjs +1 -1
  353. package/_cjs/TFuture.cjs +8 -8
  354. package/_cjs/TFuture.cjs.map +1 -1
  355. package/_cjs/TReentrantLock/api.cjs +12 -12
  356. package/_cjs/TReentrantLock/api.cjs.map +1 -1
  357. package/_cjs/TReentrantLock/definition.cjs +5 -5
  358. package/_cjs/TReentrantLock.cjs +8 -8
  359. package/_cjs/TReentrantLock.cjs.map +1 -1
  360. package/_cjs/TRef/api.cjs +2 -2
  361. package/_cjs/TRef/constructors.cjs +3 -3
  362. package/_cjs/TRef/definition.cjs +7 -7
  363. package/_cjs/TRef.cjs +8 -8
  364. package/_cjs/TRef.cjs.map +1 -1
  365. package/_cjs/TSemaphore/api.cjs +5 -5
  366. package/_cjs/TSemaphore/constructors.cjs +4 -4
  367. package/_cjs/TSemaphore/definition.cjs +1 -1
  368. package/_cjs/TSemaphore.cjs +8 -8
  369. package/_cjs/TSemaphore.cjs.map +1 -1
  370. package/_cjs/collection/immutable/Conc/dropUntilIO.cjs +3 -3
  371. package/_cjs/collection/immutable/Conc/dropWhileIO.cjs +3 -3
  372. package/_cjs/collection/immutable/Conc/filterIO.cjs +1 -1
  373. package/_cjs/collection/immutable/Conc/findIO.cjs +2 -2
  374. package/_cjs/collection/immutable/Conc/mapIO.cjs +1 -1
  375. package/_cjs/collection/immutable/Conc/takeWhileIO.cjs +3 -3
  376. package/_cjs/collection/immutable/Conc.cjs +24 -24
  377. package/_cjs/collection/immutable/Conc.cjs.map +1 -1
  378. package/_cjs/data/Exit/foreachIO.cjs +3 -3
  379. package/_cjs/internal/HashedPair.cjs +4 -4
  380. package/_cjs/internal/Hub.cjs +4 -4
  381. package/_cjs/internal/MutableQueue.cjs +2 -2
  382. package/_cjs/internal/Scheduler.cjs +1 -1
  383. package/_cjs/internal/StackTraceBuilder.cjs +2 -2
  384. package/_mjs/Cached.mjs +2 -3
  385. package/_mjs/Cached.mjs.map +1 -1
  386. package/_mjs/Channel/ChildExecutorDecision.mjs +1 -2
  387. package/_mjs/Channel/ChildExecutorDecision.mjs.map +1 -1
  388. package/_mjs/Channel/UpstreamPullRequest.mjs +1 -2
  389. package/_mjs/Channel/UpstreamPullRequest.mjs.map +1 -1
  390. package/_mjs/Channel.mjs +2 -3
  391. package/_mjs/Channel.mjs.map +1 -1
  392. package/_mjs/Clock.mjs +2 -3
  393. package/_mjs/Clock.mjs.map +1 -1
  394. package/_mjs/Console.mjs +2 -3
  395. package/_mjs/Console.mjs.map +1 -1
  396. package/_mjs/Fiber.mjs +19 -21
  397. package/_mjs/Fiber.mjs.map +1 -1
  398. package/_mjs/FiberRef/unsafe.mjs +5 -5
  399. package/_mjs/FiberRef/unsafe.mjs.map +1 -1
  400. package/_mjs/FiberRef.mjs +5 -7
  401. package/_mjs/FiberRef.mjs.map +1 -1
  402. package/_mjs/FiberRefs.mjs +1 -2
  403. package/_mjs/FiberRefs.mjs.map +1 -1
  404. package/_mjs/FiberScope.mjs +1 -2
  405. package/_mjs/FiberScope.mjs.map +1 -1
  406. package/_mjs/FiberStatus.mjs +1 -2
  407. package/_mjs/FiberStatus.mjs.map +1 -1
  408. package/_mjs/Future/api.mjs +10 -1
  409. package/_mjs/Future/api.mjs.map +1 -1
  410. package/_mjs/Future.mjs +2 -3
  411. package/_mjs/Future.mjs.map +1 -1
  412. package/_mjs/Hub.mjs +1 -2
  413. package/_mjs/Hub.mjs.map +1 -1
  414. package/_mjs/IO/api/concurrency.mjs +1 -1
  415. package/_mjs/IO/api/concurrency.mjs.map +1 -1
  416. package/_mjs/IO/api.mjs +1 -1
  417. package/_mjs/IO/api.mjs.map +1 -1
  418. package/_mjs/IO.mjs +63 -65
  419. package/_mjs/IO.mjs.map +1 -1
  420. package/_mjs/IOEnv/definition.mjs +1 -1
  421. package/_mjs/IOEnv/definition.mjs.map +1 -1
  422. package/_mjs/IOEnv/live.mjs +1 -1
  423. package/_mjs/IOEnv/live.mjs.map +1 -1
  424. package/_mjs/IOEnv.mjs +2 -3
  425. package/_mjs/IOEnv.mjs.map +1 -1
  426. package/_mjs/InterruptStatus.mjs +1 -2
  427. package/_mjs/InterruptStatus.mjs.map +1 -1
  428. package/_mjs/Layer.mjs +1 -2
  429. package/_mjs/Layer.mjs.map +1 -1
  430. package/_mjs/Logger.mjs +2 -3
  431. package/_mjs/Logger.mjs.map +1 -1
  432. package/_mjs/MVar.mjs +1 -2
  433. package/_mjs/MVar.mjs.map +1 -1
  434. package/_mjs/Push/internal.mjs +5 -6
  435. package/_mjs/Push/internal.mjs.map +1 -1
  436. package/_mjs/Push.mjs +2 -3
  437. package/_mjs/Push.mjs.map +1 -1
  438. package/_mjs/Queue/api.mjs +7 -8
  439. package/_mjs/Queue/api.mjs.map +1 -1
  440. package/_mjs/Queue.mjs +4 -5
  441. package/_mjs/Queue.mjs.map +1 -1
  442. package/_mjs/Random/live.mjs +1 -1
  443. package/_mjs/Random/live.mjs.map +1 -1
  444. package/_mjs/Random.mjs +2 -3
  445. package/_mjs/Random.mjs.map +1 -1
  446. package/_mjs/Ref/Synchronized.mjs +2 -3
  447. package/_mjs/Ref/Synchronized.mjs.map +1 -1
  448. package/_mjs/Ref/api.mjs +8 -9
  449. package/_mjs/Ref/api.mjs.map +1 -1
  450. package/_mjs/Ref.mjs +7 -9
  451. package/_mjs/Ref.mjs.map +1 -1
  452. package/_mjs/RefSubject.mjs +1 -2
  453. package/_mjs/RefSubject.mjs.map +1 -1
  454. package/_mjs/Reloadable/api.mjs +3 -3
  455. package/_mjs/Reloadable/api.mjs.map +1 -1
  456. package/_mjs/Reloadable.mjs +2 -3
  457. package/_mjs/Reloadable.mjs.map +1 -1
  458. package/_mjs/RuntimeFlags.mjs +1 -2
  459. package/_mjs/RuntimeFlags.mjs.map +1 -1
  460. package/_mjs/STM.mjs +4 -6
  461. package/_mjs/STM.mjs.map +1 -1
  462. package/_mjs/Schedule/api.mjs +2 -2
  463. package/_mjs/Schedule/api.mjs.map +1 -1
  464. package/_mjs/Schedule.mjs +2 -3
  465. package/_mjs/Schedule.mjs.map +1 -1
  466. package/_mjs/Scope/ReleaseMap.mjs +2 -3
  467. package/_mjs/Scope/ReleaseMap.mjs.map +1 -1
  468. package/_mjs/Scope.mjs +1 -2
  469. package/_mjs/Scope.mjs.map +1 -1
  470. package/_mjs/ScopedRef.mjs +1 -2
  471. package/_mjs/ScopedRef.mjs.map +1 -1
  472. package/_mjs/Semaphore.mjs +98 -42
  473. package/_mjs/Semaphore.mjs.map +1 -1
  474. package/_mjs/Sink/api.mjs +1 -1
  475. package/_mjs/Sink/api.mjs.map +1 -1
  476. package/_mjs/Sink.mjs +1 -2
  477. package/_mjs/Sink.mjs.map +1 -1
  478. package/_mjs/State.mjs +1 -2
  479. package/_mjs/State.mjs.map +1 -1
  480. package/_mjs/Stream/api.mjs +1 -1
  481. package/_mjs/Stream/api.mjs.map +1 -1
  482. package/_mjs/Stream/internal/Pull.mjs +1 -1
  483. package/_mjs/Stream/internal/Pull.mjs.map +1 -1
  484. package/_mjs/Stream/internal/Take.mjs +1 -1
  485. package/_mjs/Stream/internal/Take.mjs.map +1 -1
  486. package/_mjs/Stream.mjs +1 -2
  487. package/_mjs/Stream.mjs.map +1 -1
  488. package/_mjs/Subject.mjs +1 -2
  489. package/_mjs/Subject.mjs.map +1 -1
  490. package/_mjs/Supervisor/constructors.mjs +4 -2
  491. package/_mjs/Supervisor/constructors.mjs.map +1 -1
  492. package/_mjs/Supervisor.mjs +2 -3
  493. package/_mjs/Supervisor.mjs.map +1 -1
  494. package/_mjs/TExit.mjs +1 -2
  495. package/_mjs/TExit.mjs.map +1 -1
  496. package/_mjs/TFuture.mjs +2 -3
  497. package/_mjs/TFuture.mjs.map +1 -1
  498. package/_mjs/TReentrantLock/api.mjs +1 -1
  499. package/_mjs/TReentrantLock/api.mjs.map +1 -1
  500. package/_mjs/TReentrantLock.mjs +1 -2
  501. package/_mjs/TReentrantLock.mjs.map +1 -1
  502. package/_mjs/TRef.mjs +2 -3
  503. package/_mjs/TRef.mjs.map +1 -1
  504. package/_mjs/TSemaphore.mjs +2 -3
  505. package/_mjs/TSemaphore.mjs.map +1 -1
  506. package/_mjs/collection/immutable/Conc.mjs +5 -6
  507. package/_mjs/collection/immutable/Conc.mjs.map +1 -1
  508. package/_src/Cached.ts +2 -3
  509. package/_src/Channel/ChildExecutorDecision.ts +1 -2
  510. package/_src/Channel/UpstreamPullRequest.ts +1 -2
  511. package/_src/Channel.ts +2 -3
  512. package/_src/Clock.ts +2 -3
  513. package/_src/Console.ts +2 -3
  514. package/_src/Fiber.ts +20 -21
  515. package/_src/FiberRef.ts +6 -7
  516. package/_src/FiberRefs.ts +1 -2
  517. package/_src/FiberScope.ts +1 -2
  518. package/_src/FiberStatus.ts +1 -2
  519. package/_src/Future/api.ts +9 -0
  520. package/_src/Future.ts +2 -3
  521. package/_src/Hub.ts +1 -2
  522. package/_src/IO.ts +63 -65
  523. package/_src/IOEnv.ts +2 -3
  524. package/_src/InterruptStatus.ts +1 -2
  525. package/_src/Layer.ts +1 -2
  526. package/_src/Logger.ts +2 -3
  527. package/_src/MVar.ts +1 -2
  528. package/_src/Push/internal.ts +2 -3
  529. package/_src/Push.ts +2 -3
  530. package/_src/Queue/api.ts +7 -8
  531. package/_src/Queue.ts +4 -5
  532. package/_src/Random.ts +2 -3
  533. package/_src/Ref/Synchronized.ts +2 -3
  534. package/_src/Ref/api.ts +7 -8
  535. package/_src/Ref.ts +7 -9
  536. package/_src/RefSubject.ts +1 -2
  537. package/_src/Reloadable.ts +2 -3
  538. package/_src/RuntimeFlags.ts +1 -2
  539. package/_src/STM.ts +5 -6
  540. package/_src/Schedule.ts +2 -3
  541. package/_src/Scope/ReleaseMap.ts +2 -3
  542. package/_src/Scope.ts +1 -2
  543. package/_src/ScopedRef.ts +1 -2
  544. package/_src/Semaphore.ts +116 -38
  545. package/_src/Sink.ts +1 -2
  546. package/_src/State.ts +1 -2
  547. package/_src/Stream.ts +1 -2
  548. package/_src/Subject.ts +1 -2
  549. package/_src/Supervisor/constructors.ts +2 -0
  550. package/_src/Supervisor.ts +2 -3
  551. package/_src/TExit.ts +1 -2
  552. package/_src/TFuture.ts +2 -3
  553. package/_src/TReentrantLock.ts +1 -2
  554. package/_src/TRef.ts +2 -3
  555. package/_src/TSemaphore.ts +2 -3
  556. package/_src/collection/immutable/Conc.ts +5 -6
  557. package/collection/immutable/Conc.d.ts +5 -5
  558. package/package.json +2 -2
package/_src/Logger.ts CHANGED
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: Logger/*.ts }
3
- export * from "./Logger/definition.js";
4
- export * from "./Logger/constructors.js";
5
2
  export * from "./Logger/api.js";
3
+ export * from "./Logger/constructors.js";
4
+ export * from "./Logger/definition.js";
6
5
  // codegen:end
package/_src/MVar.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./MVar/*.ts }
3
- export * from "./MVar/definition.js";
4
2
  export * from "./MVar/api.js";
3
+ export * from "./MVar/definition.js";
5
4
  // codegen:end
@@ -56,9 +56,8 @@ export function withExhaust<R, E, A>(f: (fork: <R>(io: URIO<R, void>) => URIO<R,
56
56
  const reset = ref.set(null);
57
57
 
58
58
  const exhaustFork = <R>(io: IO<R, never, void>) =>
59
- io
60
- .ensuring(reset)
61
- .fork.flatMap((fiber) => ref.set(fiber))
59
+ fork(io.ensuring(reset))
60
+ .flatMap((fiber) => ref.set(fiber))
62
61
  .whenRef(ref, (fiber) => fiber === null).asUnit;
63
62
 
64
63
  Δ(f(exhaustFork));
package/_src/Push.ts CHANGED
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Push/*.ts }
3
- export * from "./Push/internal.js";
4
- export * from "./Push/definition.js";
5
2
  export * from "./Push/api.js";
3
+ export * from "./Push/definition.js";
4
+ export * from "./Push/internal.js";
6
5
  // codegen:end
package/_src/Queue/api.ts CHANGED
@@ -1,11 +1,10 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: api/*.ts }
3
- export * from "./api/zipWithIO.js";
4
- export * from "./api/takeN.js";
5
- export * from "./api/takeBetween.js";
6
- export * from "./api/poll.js";
7
- export * from "./api/operations.js";
8
- export * from "./api/filterOutputIO.js";
9
- export * from "./api/filterInputIO.js";
10
2
  export * from "./api/dimapIO.js";
3
+ export * from "./api/filterInputIO.js";
4
+ export * from "./api/filterOutputIO.js";
5
+ export * from "./api/operations.js";
6
+ export * from "./api/poll.js";
7
+ export * from "./api/takeBetween.js";
8
+ export * from "./api/takeN.js";
9
+ export * from "./api/zipWithIO.js";
11
10
  // codegen:end
package/_src/Queue.ts CHANGED
@@ -1,8 +1,7 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: Queue/*.ts }
3
- export * from "./Queue/strategy.js";
4
- export * from "./Queue/internal.js";
5
- export * from "./Queue/definition.js";
6
- export * from "./Queue/constructors.js";
7
2
  export * from "./Queue/api.js";
3
+ export * from "./Queue/constructors.js";
4
+ export * from "./Queue/definition.js";
5
+ export * from "./Queue/internal.js";
6
+ export * from "./Queue/strategy.js";
8
7
  // codegen:end
package/_src/Random.ts CHANGED
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Random/*.ts }
3
- export * from "./Random/live.js";
4
- export * from "./Random/definition.js";
5
2
  export * from "./Random/api.js";
3
+ export * from "./Random/definition.js";
4
+ export * from "./Random/live.js";
6
5
  // codegen:end
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Synchronized/*.ts }
3
- export * from "./Synchronized/definition.js";
4
- export * from "./Synchronized/constructors.js";
5
2
  export * from "./Synchronized/api.js";
3
+ export * from "./Synchronized/constructors.js";
4
+ export * from "./Synchronized/definition.js";
6
5
  // codegen:end
package/_src/Ref/api.ts CHANGED
@@ -2,16 +2,15 @@ import type { PRef } from "./definition.js";
2
2
 
3
3
  import { identity } from "@fncts/base/data/function";
4
4
 
5
- /* eslint-disable simple-import-sort/exports */
6
5
  // codegen:start { preset: barrel, include: api/*.ts }
7
- export * from "./api/set.js";
8
- export * from "./api/modify.js";
9
- export * from "./api/matchAll.js";
10
- export * from "./api/match.js";
11
- export * from "./api/get.js";
12
- export * from "./api/filter.js";
13
- export * from "./api/dimap.js";
14
6
  export * from "./api/collect.js";
7
+ export * from "./api/dimap.js";
8
+ export * from "./api/filter.js";
9
+ export * from "./api/get.js";
10
+ export * from "./api/match.js";
11
+ export * from "./api/matchAll.js";
12
+ export * from "./api/modify.js";
13
+ export * from "./api/set.js";
15
14
  // codegen:end
16
15
 
17
16
  /**
package/_src/Ref.ts CHANGED
@@ -1,17 +1,15 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: Ref/*.ts }
3
- export * from "./Ref/definition.js";
4
- export * from "./Ref/constructors.js";
5
2
  export * from "./Ref/api.js";
6
- export * from "./Ref/Synchronized.js";
7
- export * from "./Ref/DerivedAll.js";
8
- export * from "./Ref/Derived.js";
9
3
  export * from "./Ref/Atomic.js";
4
+ export * from "./Ref/constructors.js";
5
+ export * from "./Ref/definition.js";
6
+ export * from "./Ref/Derived.js";
7
+ export * from "./Ref/DerivedAll.js";
8
+ export * from "./Ref/Synchronized.js";
10
9
  // codegen:end
11
10
 
12
- /* eslint-disable simple-import-sort/exports */
13
11
  // codegen:start { preset: barrel, include: Ref/Synchronized/*.ts }
14
- export * from "./Ref/Synchronized/definition.js";
15
- export * from "./Ref/Synchronized/constructors.js";
16
12
  export * from "./Ref/Synchronized/api.js";
13
+ export * from "./Ref/Synchronized/constructors.js";
14
+ export * from "./Ref/Synchronized/definition.js";
17
15
  // codegen:end
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./RefSubject/*.ts }
3
- export * from "./RefSubject/definition.js";
4
2
  export * from "./RefSubject/api.js";
5
3
  export * from "./RefSubject/Atomic.js";
4
+ export * from "./RefSubject/definition.js";
6
5
  // codegen:end
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Reloadable/*.ts }
3
- export * from "./Reloadable/definition.js";
4
- export * from "./Reloadable/constructors.js";
5
2
  export * from "./Reloadable/api.js";
3
+ export * from "./Reloadable/constructors.js";
4
+ export * from "./Reloadable/definition.js";
6
5
  // codegen:end
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: RuntimeFlags/*.ts }
3
- export * from "./RuntimeFlags/RuntimeFlags.js";
4
2
  export * from "./RuntimeFlags/Patch.js";
3
+ export * from "./RuntimeFlags/RuntimeFlags.js";
5
4
  // codegen:end
package/_src/STM.ts CHANGED
@@ -1,12 +1,11 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: STM/*.ts }
3
- export * from "./STM/driver.js";
4
- export * from "./STM/definition.js";
5
2
  export * from "./STM/api.js";
3
+ export * from "./STM/definition.js";
4
+ export * from "./STM/driver.js";
6
5
  // codegen:end
7
- /* eslint-disable simple-import-sort/exports */
6
+
8
7
  // codegen:start { preset: barrel, include: STM/api/*.ts }
9
- export * from "./STM/api/core-constructors.js";
10
- export * from "./STM/api/core-api.js";
11
8
  export * from "./STM/api/atomically.js";
9
+ export * from "./STM/api/core-api.js";
10
+ export * from "./STM/api/core-constructors.js";
12
11
  // codegen:end
package/_src/Schedule.ts CHANGED
@@ -1,7 +1,6 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Schedule/*.ts }
3
- export * from "./Schedule/definition.js";
4
2
  export * from "./Schedule/api.js";
5
- export * from "./Schedule/Driver.js";
6
3
  export * from "./Schedule/Decision.js";
4
+ export * from "./Schedule/definition.js";
5
+ export * from "./Schedule/Driver.js";
7
6
  // codegen:end
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ReleaseMap/*.ts }
3
- export * from "./ReleaseMap/definition.js";
4
- export * from "./ReleaseMap/constructors.js";
5
2
  export * from "./ReleaseMap/api.js";
3
+ export * from "./ReleaseMap/constructors.js";
4
+ export * from "./ReleaseMap/definition.js";
6
5
  // codegen:end
package/_src/Scope.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Scope/*.ts, exclude: Scope/*(ReleaseMap|Finalizer).ts }
3
- export * from "./Scope/definition.js";
4
2
  export * from "./Scope/api.js";
3
+ export * from "./Scope/definition.js";
5
4
  // codegen:end
package/_src/ScopedRef.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./ScopedRef/*.ts }
3
- export * from "./ScopedRef/definition.js";
4
2
  export * from "./ScopedRef/api.js";
3
+ export * from "./ScopedRef/definition.js";
5
4
  // codegen:end
package/_src/Semaphore.ts CHANGED
@@ -1,3 +1,6 @@
1
+ import { EitherTag } from "@fncts/base/data/Either";
2
+ import { IllegalArgumentError } from "@fncts/base/data/exceptions";
3
+
1
4
  /**
2
5
  * @tsplus type fncts.io.Semaphore
3
6
  * @tsplus companion fncts.io.SemaphoreOps
@@ -5,57 +8,113 @@
5
8
  export class Semaphore {
6
9
  constructor(readonly permits: number) {}
7
10
 
8
- taken = 0;
9
- waiters = new Set<() => void>();
11
+ ref = Ref.unsafeMake<Either<ImmutableQueue<[Future<never, void>, number]>, number>>(Either.right(this.permits));
10
12
 
11
- get free(): number {
12
- return this.permits - this.taken;
13
+ available(__tsplusTrace?: string): UIO<number> {
14
+ return this.ref.get.map((_) =>
15
+ _.match(
16
+ () => 0,
17
+ (permits) => permits,
18
+ ),
19
+ );
13
20
  }
14
21
 
15
- runNext() {
16
- const next = this.waiters.values().next();
17
- if (!next.done) {
18
- this.waiters.delete(next.value);
19
- next.value();
22
+ reserve(n: number, __tsplusTrace?: string): UIO<Reservation> {
23
+ if (n < 0) {
24
+ return IO.halt(new IllegalArgumentError(`Unexpected negative ${n} permits requested`, "Semaphore.reserve"));
25
+ } else if (n === 0) {
26
+ return IO.succeedNow(new Reservation(IO.unit, IO.unit));
27
+ } else {
28
+ return Future.make<never, void>().flatMap((future) =>
29
+ this.ref.modify((state) =>
30
+ state.match(
31
+ (queue) => [
32
+ new Reservation(future.await, this.restore(future, n)),
33
+ Either.left(queue.enqueue([future, n])),
34
+ ],
35
+ (permits) => {
36
+ if (permits >= n) {
37
+ return [new Reservation(IO.unit, this.releaseN(n)), Either.right(permits - n)];
38
+ } else {
39
+ return [
40
+ new Reservation(future.await, this.restore(future, n)),
41
+ Either.left(ImmutableQueue.single([future, n - permits])),
42
+ ];
43
+ }
44
+ },
45
+ ),
46
+ ),
47
+ );
20
48
  }
21
49
  }
22
50
 
23
- take(n: number) {
24
- return IO.asyncInterrupt<never, never, number>((cb) => {
25
- if (this.free < n) {
26
- const observer = () => {
27
- if (this.free >= n) {
28
- this.waiters.delete(observer);
29
- this.taken += n;
30
- cb(IO.succeedNow(n));
51
+ restore(future: Future<never, void>, n: number, __tsplusTrace?: string): UIO<void> {
52
+ return this.ref.modify((state) =>
53
+ state.match(
54
+ (queue) =>
55
+ queue
56
+ .find(([waiter]) => waiter === future)
57
+ .match(
58
+ () => [this.releaseN(n), Either.left(queue)],
59
+ ([_, permits]) => [
60
+ this.releaseN(n - permits),
61
+ Either.left(queue.filter(([waiter]) => waiter !== future)),
62
+ ],
63
+ ),
64
+ (permits) => [IO.unit, Either.right(permits + n)],
65
+ ),
66
+ ).flatten;
67
+ }
68
+
69
+ releaseN(n: number, __tsplusTrace?: string): UIO<void> {
70
+ const self = this;
71
+
72
+ /**
73
+ * @tsplus tailRec
74
+ */
75
+ function loop(
76
+ n: number,
77
+ state: Either<ImmutableQueue<[Future<never, any>, number]>, number>,
78
+ acc: UIO<void>,
79
+ ): [UIO<void>, Either<ImmutableQueue<[Future<never, any>, number]>, number>] {
80
+ state.concrete();
81
+ switch (state._tag) {
82
+ case EitherTag.Right: {
83
+ return [acc, Either.right(state.right + n)];
84
+ }
85
+ case EitherTag.Left: {
86
+ const waiter = state.left.dequeue;
87
+
88
+ Maybe.concrete(waiter);
89
+
90
+ switch (waiter._tag) {
91
+ case MaybeTag.Nothing: {
92
+ return [acc, Either.right(self.permits)];
93
+ }
94
+ case MaybeTag.Just: {
95
+ const [[future, permits], queue] = waiter.value;
96
+ if (n > permits) {
97
+ return loop(n - permits, Either.left(queue), acc.zipLeft(future.succeed(undefined)));
98
+ } else if (n === permits) {
99
+ return [acc.zipRight(future.succeed().asUnit), Either.left(queue)];
100
+ } else {
101
+ return [acc, Either.left(queue.prepend([future, permits - n]))];
102
+ }
103
+ }
31
104
  }
32
- };
33
- this.waiters.add(observer);
34
- return Either.left(
35
- IO(() => {
36
- this.waiters.delete(observer);
37
- }),
38
- );
105
+ }
39
106
  }
40
- this.taken += n;
41
- return Either.right(IO.succeedNow(n));
42
- });
43
- }
107
+ }
44
108
 
45
- release(n: number) {
46
- return IO.withFiberRuntime<never, never, void>((fiber) => {
47
- this.taken -= n;
48
- fiber.getFiberRef(FiberRef.currentScheduler).scheduleTask(() => {
49
- this.waiters.forEach((wake) => wake());
50
- });
51
- return IO.unit;
52
- });
109
+ return this.ref.modify((state) => loop(n, state, IO.unit)).flatten;
53
110
  }
54
111
 
55
112
  withPermits(permits: number) {
56
113
  return <R, E, A>(io: IO<R, E, A>): IO<R, E, A> => {
57
- return IO.uninterruptibleMask((restore) =>
58
- restore(this.take(permits)).flatMap((permits) => restore(io).ensuring(this.release(permits))),
114
+ return IO.bracket(
115
+ this.reserve(permits),
116
+ (reservation) => reservation.acquire > io,
117
+ (reservation) => reservation.release,
59
118
  );
60
119
  };
61
120
  }
@@ -63,6 +122,25 @@ export class Semaphore {
63
122
  withPermit<R, E, A>(io: IO<R, E, A>): IO<R, E, A> {
64
123
  return this.withPermits(1)(io);
65
124
  }
125
+
126
+ withPermitsScoped(permits: number) {
127
+ return <R, E, A>(io: IO<R, E, A>): IO<Scope | R, E, A> => {
128
+ return IO.acquireRelease(this.reserve(permits), (reservation) => reservation.release).flatMap(
129
+ (reservation) => reservation.acquire > io,
130
+ );
131
+ };
132
+ }
133
+
134
+ withPermitScoped<R, E, A>(io: IO<R, E, A>): IO<Scope | R, E, A> {
135
+ return this.withPermitsScoped(1)(io);
136
+ }
137
+ }
138
+
139
+ export class Reservation {
140
+ constructor(
141
+ readonly acquire: UIO<void>,
142
+ readonly release: UIO<void>,
143
+ ) {}
66
144
  }
67
145
 
68
146
  /**
package/_src/Sink.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Sink/*.ts }
3
- export * from "./Sink/definition.js";
4
2
  export * from "./Sink/api.js";
3
+ export * from "./Sink/definition.js";
5
4
  // codegen:end
package/_src/State.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./State/*.ts, exclude: State/internal.ts }
3
- export * from "./State/definition.js";
4
2
  export * from "./State/api.js";
3
+ export * from "./State/definition.js";
5
4
  // codegen:end
package/_src/Stream.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Stream/*.ts, exclude: Stream/*(DebounceState|Handoff|Pull|SinkEndReason|Take).ts }
3
- export * from "./Stream/definition.js";
4
2
  export * from "./Stream/api.js";
3
+ export * from "./Stream/definition.js";
5
4
  // codegen:end
package/_src/Subject.ts CHANGED
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Subject/*.ts }
3
- export * from "./Subject/definition.js";
4
2
  export * from "./Subject/api.js";
5
3
  export * from "./Subject/Atomic.js";
4
+ export * from "./Subject/definition.js";
6
5
  // codegen:end
@@ -17,9 +17,11 @@ export function unsafeTrack(weak: boolean): Supervisor<Conc<Fiber.Runtime<any, a
17
17
  _parent: Maybe<Fiber.Runtime<E, A>>,
18
18
  fiber: Fiber.Runtime<E, A>,
19
19
  ) {
20
+ // @ts-expect-error
20
21
  set.add(fiber);
21
22
  }
22
23
  unsafeOnEnd<E, A>(_value: Exit<E, A>, fiber: Fiber.Runtime<E, A>) {
24
+ // @ts-expect-error
23
25
  set.delete(fiber);
24
26
  }
25
27
  })();
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: Supervisor/*.ts }
3
- export * from "./Supervisor/definition.js";
4
- export * from "./Supervisor/constructors.js";
5
2
  export * from "./Supervisor/api.js";
3
+ export * from "./Supervisor/constructors.js";
4
+ export * from "./Supervisor/definition.js";
6
5
  // codegen:end
package/_src/TExit.ts CHANGED
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./TExit/*.ts }
3
- export * from "./TExit/definition.js";
4
2
  export * from "./TExit/constructors.js";
3
+ export * from "./TExit/definition.js";
5
4
  // codegen:end
package/_src/TFuture.ts CHANGED
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: TFuture/*.ts }
3
- export * from "./TFuture/definition.js";
4
- export * from "./TFuture/constructors.js";
5
2
  export * from "./TFuture/api.js";
3
+ export * from "./TFuture/constructors.js";
4
+ export * from "./TFuture/definition.js";
6
5
  // codegen:end
@@ -1,5 +1,4 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: TReentrantLock/*.ts }
3
- export * from "./TReentrantLock/definition.js";
4
2
  export * from "./TReentrantLock/api.js";
3
+ export * from "./TReentrantLock/definition.js";
5
4
  // codegen:end
package/_src/TRef.ts CHANGED
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: TRef/*.ts }
3
- export * from "./TRef/definition.js";
4
- export * from "./TRef/constructors.js";
5
2
  export * from "./TRef/api.js";
3
+ export * from "./TRef/constructors.js";
4
+ export * from "./TRef/definition.js";
6
5
  // codegen:end
@@ -1,6 +1,5 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: TSemaphore/*.ts }
3
- export * from "./TSemaphore/definition.js";
4
- export * from "./TSemaphore/constructors.js";
5
2
  export * from "./TSemaphore/api.js";
3
+ export * from "./TSemaphore/constructors.js";
4
+ export * from "./TSemaphore/definition.js";
6
5
  // codegen:end
@@ -1,9 +1,8 @@
1
- /* eslint-disable simple-import-sort/exports */
2
1
  // codegen:start { preset: barrel, include: ./Conc/*.ts }
3
- export * from "./Conc/takeWhileIO.js";
4
- export * from "./Conc/mapIO.js";
5
- export * from "./Conc/findIO.js";
6
- export * from "./Conc/filterIO.js";
7
- export * from "./Conc/dropWhileIO.js";
8
2
  export * from "./Conc/dropUntilIO.js";
3
+ export * from "./Conc/dropWhileIO.js";
4
+ export * from "./Conc/filterIO.js";
5
+ export * from "./Conc/findIO.js";
6
+ export * from "./Conc/mapIO.js";
7
+ export * from "./Conc/takeWhileIO.js";
9
8
  // codegen:end
@@ -1,6 +1,6 @@
1
- export * from "./Conc/takeWhileIO.js";
2
- export * from "./Conc/mapIO.js";
3
- export * from "./Conc/findIO.js";
4
- export * from "./Conc/filterIO.js";
5
- export * from "./Conc/dropWhileIO.js";
6
1
  export * from "./Conc/dropUntilIO.js";
2
+ export * from "./Conc/dropWhileIO.js";
3
+ export * from "./Conc/filterIO.js";
4
+ export * from "./Conc/findIO.js";
5
+ export * from "./Conc/mapIO.js";
6
+ export * from "./Conc/takeWhileIO.js";
package/package.json CHANGED
@@ -1,8 +1,8 @@
1
1
  {
2
2
  "name": "@fncts/io",
3
- "version": "0.0.45",
3
+ "version": "0.0.46",
4
4
  "dependencies": {
5
- "@fncts/base": "0.0.37",
5
+ "@fncts/base": "0.0.38",
6
6
  "@fncts/transformers": "0.0.10",
7
7
  "@fncts/typelevel": "0.0.19"
8
8
  },