The AsyncEmitter needs to signal to its worker thread when it is time to flush all events and gracefully shutdown. Currently this is done via awkward thread-safe boolean flags (AtomicBooleans). A neater pattern is to use a ADT, so the queue of events signals various actions the worker thread should perform:
Enqueue a new payload
Flush events
Terminate
This is a more robust method of implementing cross-thread communication, and it is more extensible to other emitters (see the forthcoming http4s emitter)
The AsyncEmitter needs to signal to its worker thread when it is time to flush all events and gracefully shutdown. Currently this is done via awkward thread-safe boolean flags (AtomicBooleans). A neater pattern is to use a ADT, so the queue of events signals various actions the worker thread should perform:
This is a more robust method of implementing cross-thread communication, and it is more extensible to other emitters (see the forthcoming http4s emitter)