Monday, July 18, 2016

AsyncMemoryStream

More fun with my MT memory-based stream. Threaded systems are pretty exciting to write, in a "riding a motorcycle naked the wrong direction down the highway" sort of way.

I finished the async Stream methods (BeginRead/BeginWrite) and wrote some good unit tests for them, although in retrospect I'm not even positive I'm going to use them.

I'm adding an accessor now that lets the user know if bytes are available to be read on the stream. Unfortunately I'm using a volatile bool. I understand volatile to be the spawn of beezlebub, but I'm not sure what a better approach would be. I can't just ask for the length of the stream, because that takes a monitor lock, and that could block for the whole duration of a Write--rather defeating the point.

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.