MCPcopy Create free account
hub / github.com/apple/foundationdb / replace

Method replace

flow/WriteOnlySet.actor.cpp:74–96  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

72
73template <class T, class IndexType, IndexType CAPACITY>
74bool WriteOnlySet<T, IndexType, CAPACITY>::replace(Index idx, const Reference<T>& lineage) {
75 auto lineagePtr = reinterpret_cast<uintptr_t>(lineage.getPtr());
76 if (lineage.isValid()) {
77 lineage->addref();
78 }
79 ASSERT((lineagePtr % 2) == 0); // this needs to be at least 2-byte aligned
80
81 while (true) {
82 auto ptr = _set[idx].load();
83 if (ptr & LOCK) {
84 _set[idx].store(lineagePtr);
85 ASSERT(freeList.push(reinterpret_cast<T*>(ptr ^ LOCK)));
86 return false;
87 } else {
88 if (_set[idx].compare_exchange_strong(ptr, lineagePtr)) {
89 if (ptr) {
90 reinterpret_cast<T*>(ptr)->delref();
91 }
92 return ptr != 0;
93 }
94 }
95 }
96}
97
98template <class T, class IndexType, IndexType CAPACITY>
99WriteOnlySet<T, IndexType, CAPACITY>::WriteOnlySet() : _set(CAPACITY) {

Callers 15

parseLineFunction · 0.45
actorFileFunction · 0.45
gen_compile_db.pyFile · 0.45
collect_symsFunction · 0.45
CommandMethod · 0.45
makeCommandMethod · 0.45
quoteMethod · 0.45
unescapeLiteralsFunction · 0.45
slashToEndMethod · 0.45
updateBackupURLFunction · 0.45
run_simulation_testFunction · 0.45
save_configMethod · 0.45

Calls 7

getPtrMethod · 0.45
isValidMethod · 0.45
addrefMethod · 0.45
loadMethod · 0.45
storeMethod · 0.45
pushMethod · 0.45
delrefMethod · 0.45

Tested by 1

run_simulation_testFunction · 0.36