Hacker News new | ask | show | jobs
by std_throwaway 4154 days ago
In that case you don't want to sleep. You want to wait until a condition (new data) or a timeout (100ms) occurs.

The reasoning is that you don't know how much data will arrive in the next 100ms and if you sleep either a buffer could overrun or something else could block. Therefore you need to flush the buffer either when enough data has accumulated or if a timeout has occured.

1 comments

I can see where you're coming from. For my particular apication that's not a concern (and I have sequence numbers to know when I've dropped data).