Simple question - is there a way to have an event that is triggered the moment data arrives on an input stream?
In our open source project we're just looping until we see an end of message character (piecing togegher the message along the way). The loop pauses 300ms between loops to reduce CPU utilization but this is still a far cry from "event driven programming".
sleeping too long is detrimental to throughput sleeping too short is detrimental to CPU, other processes, and context-switch intensive.
I'd like to clean up the readUpToCharacter
function in the above link so that it waits for data in an event driven manner.
Looking for some clever design patterns for this seemingly common problem.
Thanks!!!