()
| 273 | }) |
| 274 | } |
| 275 | unsafeTake(): Exit<A, E | NoSuchElementException> | undefined { |
| 276 | if (this.state._tag === "Done") { |
| 277 | return core.exitZipRight(this.state.exit, core.exitFail(new NoSuchElementException())) |
| 278 | } |
| 279 | let message: A |
| 280 | if (this.messagesChunk.length > 0) { |
| 281 | message = Chunk.unsafeHead(this.messagesChunk) |
| 282 | this.messagesChunk = Chunk.drop(this.messagesChunk, 1) |
| 283 | } else if (this.messages.length > 0) { |
| 284 | message = this.messages[0] |
| 285 | this.messagesChunk = Chunk.drop(Chunk.unsafeFromArray(this.messages), 1) |
| 286 | this.messages = [] |
| 287 | } else if (this.capacity <= 0 && this.state.offers.size > 0) { |
| 288 | this.capacity = 1 |
| 289 | this.releaseCapacity() |
| 290 | this.capacity = 0 |
| 291 | return this.messages.length > 0 ? core.exitSucceed(this.messages.pop()!) : undefined |
| 292 | } else { |
| 293 | return undefined |
| 294 | } |
| 295 | this.releaseCapacity() |
| 296 | return core.exitSucceed(message) |
| 297 | } |
| 298 | take: Effect<A, E | NoSuchElementException> = core.suspend(() => |
| 299 | this.unsafeTake() ?? core.zipRight(this.awaitTake, this.take) |
| 300 | ) |
no test coverage detected