spawn package:pipes-concurrency

Spawn a mailbox using the specified Buffer to store messages Using send on the Output
  • fails and returns False if the mailbox is sealed, otherwise it:
  • retries if the mailbox is full, or:
  • adds a message to the mailbox and returns True.
Using recv on the Input:
  • retrieves a message from the mailbox wrapped in Just if the mailbox is not empty, otherwise it:
  • retries if the mailbox is not sealed, or:
  • fails and returns Nothing.
If either the Input or Output is garbage collected the mailbox will become sealed.
Like spawn, but also returns an action to manually seal the mailbox early:
(output, input, seal) <- spawn' buffer
...
Use the seal action to allow early cleanup of readers and writers to the mailbox without waiting for the next garbage collection cycle.
withSpawn passes its enclosed action an Output and Input like you'd get from spawn, but automatically seals them after the action completes. This can be used when you need the sealing behavior available from 'spawn'', but want to work at a bit higher level:
withSpawn buffer $ \(output, input) -> ...
withSpawn is exception-safe, since it uses bracket internally.