P
Peter Morris
I'm reading Joe Duffy's book "Concurrent Programming on Windows" (highly
recommended by the way!).
I am surprised by the following code in a class
private volatile int m_Completed; //0==Not complete, 1==Complete
public bool IsCompleted
{
get { return m_Completed == 1; }
}
I'd have been inclined to use "private volatile bool". This leads me to
believe there must be a problem with volatile booleans? Surely writing to a
boolean is a single CPU cycle just as it is with writing an int? So why
would he do it this way? What don't I know?
recommended by the way!).
I am surprised by the following code in a class
private volatile int m_Completed; //0==Not complete, 1==Complete
public bool IsCompleted
{
get { return m_Completed == 1; }
}
I'd have been inclined to use "private volatile bool". This leads me to
believe there must be a problem with volatile booleans? Surely writing to a
boolean is a single CPU cycle just as it is with writing an int? So why
would he do it this way? What don't I know?