MCPcopy
hub / github.com/Effect-TS/effect / QueueSpy

Class QueueSpy

packages/effect/test/Sink/constructors.test.ts:91–191  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

89const createQueueSpy = <A>(queue: Queue.Queue<A>): Queue.Queue<A> => new QueueSpy(queue)
90
91class QueueSpy<A> extends Effectable.Class<A> implements Queue.Queue<A> {
92 readonly [Queue.DequeueTypeId] = internalQueue.dequeueVariance
93 readonly [Queue.EnqueueTypeId] = internalQueue.enqueueVariance
94 private isShutdownInternal = false
95 readonly queue: Queue.BackingQueue<A>
96 readonly shutdownFlag: MutableRef.MutableRef<boolean>
97 readonly shutdownHook: Deferred.Deferred<void, never>
98 readonly strategy: Queue.Strategy<A>
99 readonly takers: MutableQueue.MutableQueue<Deferred.Deferred<A, never>>
100
101 constructor(readonly backingQueue: Queue.Queue<A>) {
102 super()
103 this.queue = backingQueue.queue
104 this.shutdownFlag = backingQueue.shutdownFlag
105 this.shutdownHook = backingQueue.shutdownHook
106 this.strategy = backingQueue.strategy
107 this.takers = backingQueue.takers
108 }
109
110 commit() {
111 return this.take
112 }
113
114 pipe() {
115 return pipeArguments(this, arguments)
116 }
117
118 unsafeOffer(value: A): boolean {
119 return Queue.unsafeOffer(this.backingQueue, value)
120 }
121
122 offer(a: A) {
123 return Queue.offer(this.backingQueue, a)
124 }
125
126 offerAll(elements: Iterable<A>) {
127 return Queue.offerAll(this.backingQueue, elements)
128 }
129
130 capacity(): number {
131 return Queue.capacity(this.backingQueue)
132 }
133
134 get size(): Effect.Effect<number> {
135 return Queue.size(this.backingQueue)
136 }
137
138 unsafeSize(): Option.Option<number> {
139 return this.backingQueue.unsafeSize()
140 }
141
142 get awaitShutdown(): Effect.Effect<void> {
143 return Queue.awaitShutdown(this.backingQueue)
144 }
145
146 isActive(): boolean {
147 return !this.isShutdownInternal
148 }

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected