C12Adapter Opensource C++ Interface
MChannel::ReadTimeoutSavior Class Reference

Temporarily overrides read timeout with a new value using scope rules. More...

Public Member Functions

 ReadTimeoutSavior (MChannel *channel, unsigned newTimeout)
 Constructor saves the previous value of read timeout and sets the new one given.
 
 ~ReadTimeoutSavior ()
 Destructor restores the previously saved timeout.
 

Detailed Description

Temporarily overrides read timeout with a new value using scope rules.

Constructor saves the current read timeout value, and sets a new given timeout. Destructor restores the previously saved value.

Usage example:

{
.... // here the usual read timeout applies
ReadPacketHeader(channel);
ReadTimeoutSavior timeoutSavior(channel, intercharacterTimeout);
ReadTheRestOfThePacketWithIntercharacterTimeout(channel);
.... // here the timeout will be restored
}