| 446 | * @since 4.0.0 |
| 447 | */ |
| 448 | export const make = <A, E = never>( |
| 449 | options?: { |
| 450 | readonly capacity?: number | undefined |
| 451 | readonly strategy?: "suspend" | "dropping" | "sliding" | undefined |
| 452 | } | undefined |
| 453 | ): Effect<Queue<A, E>> => |
| 454 | core.withFiber((fiber) => { |
| 455 | const self = Object.create(QueueProto) |
| 456 | self.dispatcher = fiber.currentDispatcher |
| 457 | self.capacity = options?.capacity ?? Number.POSITIVE_INFINITY |
| 458 | self.strategy = options?.strategy ?? "suspend" |
| 459 | self.messages = MutableList.make() |
| 460 | self.scheduleRunning = false |
| 461 | self.state = { |
| 462 | _tag: "Open", |
| 463 | takers: new Set(), |
| 464 | offers: new Set(), |
| 465 | awaiters: new Set() |
| 466 | } |
| 467 | return internalEffect.succeed(self) |
| 468 | }) |
| 469 | |
| 470 | /** |
| 471 | * Creates a bounded queue with the specified capacity that uses backpressure strategy. |