| 291 | |
| 292 | /** @internal */ |
| 293 | export class FiberRuntime<in out A, in out E = never> extends Effectable.Class<A, E> |
| 294 | implements Fiber.RuntimeFiber<A, E> |
| 295 | { |
| 296 | readonly [internalFiber.FiberTypeId] = internalFiber.fiberVariance |
| 297 | readonly [internalFiber.RuntimeFiberTypeId] = runtimeFiberVariance |
| 298 | private _fiberRefs: FiberRefs.FiberRefs |
| 299 | private _fiberId: FiberId.Runtime |
| 300 | private _queue = new Array<FiberMessage.FiberMessage>() |
| 301 | private _children: Set<FiberRuntime<any, any>> | null = null |
| 302 | private _observers = new Array<(exit: Exit.Exit<A, E>) => void>() |
| 303 | private _running = false |
| 304 | private _stack: Array<core.Continuation> = [] |
| 305 | private _asyncInterruptor: ((effect: Effect.Effect<any, any, any>) => any) | null = null |
| 306 | private _asyncBlockingOn: FiberId.FiberId | null = null |
| 307 | private _exitValue: Exit.Exit<A, E> | null = null |
| 308 | private _steps: Array<Snapshot> = [] |
| 309 | private _isYielding = false |
| 310 | |
| 311 | public currentRuntimeFlags: RuntimeFlags.RuntimeFlags |
| 312 | public currentOpCount: number = 0 |
| 313 | public currentSupervisor!: Supervisor.Supervisor<any> |
| 314 | public currentScheduler!: Scheduler |
| 315 | public currentTracer!: Tracer.Tracer |
| 316 | public currentSpan!: Tracer.AnySpan | undefined |
| 317 | public currentContext!: Context.Context<never> |
| 318 | public currentDefaultServices!: Context.Context<DefaultServices> |
| 319 | |
| 320 | constructor( |
| 321 | fiberId: FiberId.Runtime, |
| 322 | fiberRefs0: FiberRefs.FiberRefs, |
| 323 | runtimeFlags0: RuntimeFlags.RuntimeFlags |
| 324 | ) { |
| 325 | super() |
| 326 | this.currentRuntimeFlags = runtimeFlags0 |
| 327 | this._fiberId = fiberId |
| 328 | this._fiberRefs = fiberRefs0 |
| 329 | if (runtimeFlags_.runtimeMetrics(runtimeFlags0)) { |
| 330 | const tags = this.getFiberRef(core.currentMetricLabels) |
| 331 | fiberStarted.unsafeUpdate(1, tags) |
| 332 | fiberActive.unsafeUpdate(1, tags) |
| 333 | } |
| 334 | this.refreshRefCache() |
| 335 | } |
| 336 | |
| 337 | commit(): Effect.Effect<A, E, never> { |
| 338 | return internalFiber.join(this) |
| 339 | } |
| 340 | |
| 341 | /** |
| 342 | * The identity of the fiber. |
| 343 | */ |
| 344 | id(): FiberId.Runtime { |
| 345 | return this._fiberId |
| 346 | } |
| 347 | |
| 348 | /** |
| 349 | * Begins execution of the effect associated with this fiber on in the |
| 350 | * background. This can be called to "kick off" execution of a fiber after |
nothing calls this directly
no test coverage detected