This source file includes following definitions.
- ReadBegin
- ReadRetry
- WriteBegin
- WriteEnd
#include "content/common/one_writer_seqlock.h"
namespace content {
OneWriterSeqLock::OneWriterSeqLock()
: sequence_(0) {
}
base::subtle::Atomic32 OneWriterSeqLock::ReadBegin() {
base::subtle::Atomic32 version;
for (;;) {
version = base::subtle::NoBarrier_Load(&sequence_);
if ((version & 1) == 0)
break;
base::PlatformThread::YieldCurrentThread();
}
return version;
}
bool OneWriterSeqLock::ReadRetry(base::subtle::Atomic32 version) {
return base::subtle::Release_Load(&sequence_) != version;
}
void OneWriterSeqLock::WriteBegin() {
base::subtle::Barrier_AtomicIncrement(&sequence_, 1);
}
void OneWriterSeqLock::WriteEnd() {
base::subtle::Barrier_AtomicIncrement(&sequence_, 1);
}
}