volatile declarator
The volatile keyword is a type qualifier used to declare that an object can be modified in the program by something other than statements, such as the operating system, the hardware, or a concurrently executing thread.
The following example declares a volatile integer nVint whose value can be modified by external processes:
int volatile nVint;
Objects declared as volatile are not used in optimizations because their value can change at any time. The system always reads the current value of a volatile object at the point it is requested, even if the previous instruction asked for a value from the same object. Also, the value of the object is written immediately on assignment.
One use of the volatile qualifier is to provide access to memory locations used by asynchronous processes such as interrupt handlers.
This sounds like a great replacement for mutexes. If it re-reads it every time it is accessed, and re-writes it every time it is changes, wouldn''t that eleminate the need for a mutex? I was reading some mutex tutorials on flipcode earlier when gamedev was down (or maybe it was just my connection), and they have a really neat implementation form mutexes. I thought I remembered something foggy about a volatile keyword, so I looked it up and here it is. Will it replace a mutex?
--------------------You are not a real programmer until you end all your sentences with semicolons; (c) 2000 ROAD Programming
You are unique. Just like everybody else.
"Mechanical engineers design weapons; civil engineers design targets."
Visit the ROAD Programming Website for more programming help.