Code comment on *mut Stream effect on thread safety

This commit is contained in:
Martin Algesten
2019-10-20 14:06:24 +02:00
parent 8871183df0
commit d9b8fef9a0
2 changed files with 6 additions and 1 deletions

View File

@@ -557,6 +557,8 @@ fn read_next_line<R: Read>(reader: &mut R) -> IoResult<String> {
/// that api provides no way for us to get the underlying stream back. We need
/// to get the stream both for sending responses and for pooling.
pub(crate) struct ReclaimingRead {
// this pointer forces ReclaimingRead to be !Send and !Sync. That's a good
// thing, cause passing this reader around threads would not be safe.
stream: *mut Stream,
dealloc: bool, // whether we are to dealloc stream on drop
}