ursus
06/28/2025, 3:29 PMaudio processing producer consumer
system. Typically in blocking world that is solved with 2 threads and a RingBuffer
.
Say now I want to do that in ktor server, where producer is a web socket.
The ktor ws api is suspending.
Does it make sense to implement this with `Channel`s? Don’t channels require immutable data?
How would you go about it?
Is it a good idea to flatten a byte array and send each byte into a Channel?Bogdan Vladoiu Lbs
07/02/2025, 5:23 AMBogdan Vladoiu Lbs
07/02/2025, 5:28 AMBogdan Vladoiu Lbs
07/02/2025, 5:30 AMBogdan Vladoiu Lbs
07/02/2025, 5:36 AMval blockingCircularBuffer = MutableSharedFlow<String>(
replay = 0, // No replay needed for a strict blocking buffer behavior
extraBufferCapacity = bufferSize,
onBufferOverflow = BufferOverflow.SUSPEND // This makes emit() block when full, you can change it to drop oldest/drop latest
)
Bogdan Vladoiu Lbs
07/02/2025, 5:37 AM