( fiberId: FiberId.FiberId, stm: STM.STM<A, E, R>, env: Context.Context<R>, scheduler: Scheduler.Scheduler, priority: number )
| 298 | |
| 299 | /** @internal */ |
| 300 | const tryCommitSync = <A, E, R>( |
| 301 | fiberId: FiberId.FiberId, |
| 302 | stm: STM.STM<A, E, R>, |
| 303 | env: Context.Context<R>, |
| 304 | scheduler: Scheduler.Scheduler, |
| 305 | priority: number |
| 306 | ): TryCommit.TryCommit<A, E> => { |
| 307 | const journal: Journal.Journal = new Map() |
| 308 | const tExit = new STMDriver(stm, journal, fiberId, env).run() |
| 309 | const analysis = Journal.analyzeJournal(journal) |
| 310 | |
| 311 | if (analysis === Journal.JournalAnalysisReadWrite && TExit.isSuccess(tExit)) { |
| 312 | Journal.commitJournal(journal) |
| 313 | } else if (analysis === Journal.JournalAnalysisInvalid) { |
| 314 | throw new Error( |
| 315 | "BUG: STM.TryCommit.tryCommitSync - please report an issue at https://github.com/Effect-TS/effect/issues" |
| 316 | ) |
| 317 | } |
| 318 | |
| 319 | switch (tExit._tag) { |
| 320 | case TExitOpCodes.OP_SUCCEED: { |
| 321 | return completeTodos(Exit.succeed(tExit.value), journal, scheduler, priority) |
| 322 | } |
| 323 | case TExitOpCodes.OP_FAIL: { |
| 324 | const cause = Cause.fail(tExit.error) |
| 325 | return completeTodos( |
| 326 | Exit.failCause(cause), |
| 327 | journal, |
| 328 | scheduler, |
| 329 | priority |
| 330 | ) |
| 331 | } |
| 332 | case TExitOpCodes.OP_DIE: { |
| 333 | const cause = Cause.die(tExit.defect) |
| 334 | return completeTodos( |
| 335 | Exit.failCause(cause), |
| 336 | journal, |
| 337 | scheduler, |
| 338 | priority |
| 339 | ) |
| 340 | } |
| 341 | case TExitOpCodes.OP_INTERRUPT: { |
| 342 | const cause = Cause.interrupt(fiberId) |
| 343 | return completeTodos( |
| 344 | Exit.failCause(cause), |
| 345 | journal, |
| 346 | scheduler, |
| 347 | priority |
| 348 | ) |
| 349 | } |
| 350 | case TExitOpCodes.OP_RETRY: { |
| 351 | return TryCommit.suspend(journal) |
| 352 | } |
| 353 | } |
| 354 | } |
| 355 | |
| 356 | /** @internal */ |
| 357 | const tryCommitAsync = <A, E, R>( |
no test coverage detected