// ets_tracing: off import { None } from "../Fiber/id.js" import { AtomicBoolean } from "../Support/AtomicBoolean/index.js" import type { MutableQueue } from "../Support/MutableQueue/index.js" import { Bounded, Unbounded } from "../Support/MutableQueue/index.js" import { BackPressureStrategy, unsafeCreate } from "./api.js" import type { Strategy } from "./core.js" import { DroppingStrategy, SlidingStrategy } from "./core.js" import * as P from "./promise.js" import type { Queue } from "./xqueue.js" /** * Unsafely creates a queue * * @ets_data_first unsafeCreateQueue_ */ export function unsafeCreateQueue(strategy: Strategy) { return (queue: MutableQueue) => unsafeCreateQueue_(queue, strategy) } /** * Unsafely creates a queue */ export function unsafeCreateQueue_(queue: MutableQueue, strategy: Strategy) { return unsafeCreate( queue, new Unbounded(), P.unsafeMake(None), new AtomicBoolean(false), strategy ) } /** * Unsafely creates a sliding queue */ export function unsafeMakeSliding(capacity: number): Queue { return unsafeCreateQueue_(new Bounded(capacity), new SlidingStrategy()) } /** * Unsafely creates a unbounded queue */ export function unsafeMakeUnbounded(): Queue { return unsafeCreateQueue_(new Unbounded(), new DroppingStrategy()) } /** * Unsafely creates a dropping queue */ export function unsafeMakeDropping(capacity: number): Queue { return unsafeCreateQueue_(new Bounded(capacity), new DroppingStrategy()) } /** * Unsafely creates a bounded queue */ export function unsafeMakeBounded(capacity: number): Queue { return unsafeCreateQueue_(new Bounded(capacity), new BackPressureStrategy()) }