Double-checked Locking - Usage in Microsoft Visual C++

Usage in Microsoft Visual C++

Double-checked locking can be implemented in Visual C++ 2005 and above if the pointer to the resource is declared with the C++ keyword volatile. Visual C++ 2005 guarantees that volatile variables will behave as fence instructions, as in J2SE 5.0, preventing both compiler and CPU arrangement of reads and writes with acquire semantics (for reads) and release semantics (for writes). There is no such guarantee in previous versions of Visual C++. However, marking the pointer to the resource as volatile may harm performance elsewhere, if the pointer declaration is visible elsewhere in code, by forcing the compiler to treat it as a fence elsewhere, even when it is not necessary.

Read more about this topic:  Double-checked Locking

Famous quotes containing the words usage and/or visual:

    I am using it [the word ‘perceive’] here in such a way that to say of an object that it is perceived does not entail saying that it exists in any sense at all. And this is a perfectly correct and familiar usage of the word.
    —A.J. (Alfred Jules)

    Unlike any other visual image, a photograph is not a rendering, an imitation or an interpretation of its subject, but actually a trace of it. No painting or drawing, however naturalist, belongs to its subject in the way that a photograph does.
    John Berger (b. 1926)