Boost logo

Boost Users :

Subject: [Boost-users] [thread] variables in thread examples require 'volatile'?
From: Gabriel Redner (gredner_at_[hidden])
Date: 2009-12-07 18:59:28

Dear Boosters,

I'm involved in a bit of a dispute in which a colleague is claiming
that 'volatile' is necessary to make certain synchronization patterns
correct. As part of my response I pointed out that the boost.thread
examples don't use it, but he maintains his position - saying that the
examples are flawed. I'm frankly somewhat out of my element here, and
I'd like to get input from people who have presumably thought about
this stuff a good deal.

The example in question is here, under "synopsis":

The claim is that 'volatile' is needed on the boolean, otherwise the
compiler might cache the boolean in a register, and the loop would
never exit. He cites for support two articles:

Who's right?


Boost-users list run by williamkempf at, kalb at, bjorn.karlsson at, gregod at, wekempf at