Shoud a method that waits for a change of state be const?
Posted
by Space_C0wb0y
on Stack Overflow
See other posts from Stack Overflow
or by Space_C0wb0y
Published on 2010-03-26T14:04:54Z
Indexed on
2010/03/26
14:13 UTC
Read the original article
Hit count: 112
In a multithreaded scenario, I have a method like this:
bool WaitForChange( time_duration WaitTime ) const;
This method waits either until the state of the object has changed and returns true, or until the timeout times out (how do you say that?) and returns false.
My intuition is, that const
is to protect against unwanted side-effects of the method itself, so this is fine. But then again, some user might think that the state of the could not have changed, since the method is declared const
. Is that user stupid, or should I make the method non-const
in order to avoid confusion?
© Stack Overflow or respective owner