(self: TxPriorityQueue<A>)
| 386 | * @since 2.0.0 |
| 387 | */ |
| 388 | export const take = <A>(self: TxPriorityQueue<A>): Effect.Effect<A> => |
| 389 | Effect.gen(function*() { |
| 390 | const chunk = yield* TxRef.get(self.ref) |
| 391 | const head = C.head(chunk) |
| 392 | if (O.isNone(head)) { |
| 393 | return yield* Effect.txRetry |
| 394 | } |
| 395 | yield* TxRef.set(self.ref, C.drop(chunk, 1)) |
| 396 | return head.value |
| 397 | }).pipe(Effect.tx) |
| 398 | |
| 399 | /** |
| 400 | * Takes all elements from the queue, returning them in priority order. |