Boost logo

Boost Users :

Subject: [Boost-users] [Thread] How to invoke a memory fence?
From: Radosavljevic, Branko (branko.radosavljevic_at_[hidden])
Date: 2009-01-27 16:55:31


I have a newbie question about using Boost.Thread to invoke a memory
fence operation. What are the memory fence guarantees associated
with the synchronization concepts in Boost.Thread?

My specific use case involves one writer and several readers.
For example, something like:

bool available = false;
int value;

// Writer thread
value = getValue();
available = true;

// A reader thread
while (!available)
    yield();
doSomething(value);

In other words, the write to available should have release
semantics, and the read from available should have acquire
semantics. I realize I can use platform-specific commands,
but I'd rather not. I assume that if I want to use Boost.Thread,
I'll need to use a mutex, but I don't see any discussion
of memory fence issues in the documentation.

Thanks,
Branko

Any information contained in or attached to this e-mail is intended solely for the use of the intended recipient(s), is confidential and may contain information that is legally privileged. If you are not an intended recipient of this e-mail, please notify the sender of the delivery error and then please delete and destroy all copies and attachments, and be advised that any review or dissemination of, or the taking of any action in reliance on, the information contained in or attached to this e-mail is expressly prohibited. See http://www.bankofamerica.com/emaildisclaimer (if this link is not clickable, please copy and paste the link into your browser address bar) for further important information on confidentiality, the risks inherent in electronic communication (including the possibility that e-mail messages cannot be guaranteed to be secure or free of errors or viruses), some of our policies regarding transactions and pricing and certain other matters.


Boost-users list run by williamkempf at hotmail.com, kalb at libertysoft.com, bjorn.karlsson at readsoft.com, gregod at cs.rpi.edu, wekempf at cox.net