1
0
Fork 0

ASAN runtime errors

This commit is contained in:
Kaveh Vahedipour 2017-04-28 11:57:20 +02:00
parent bb3df8cc84
commit c51e144678
2 changed files with 18 additions and 16 deletions

View File

@ -39,3 +39,20 @@ std::atomic<int> arangodb::basics::DataProtector::_last(0);
// TODO: Reactivate this template instantiation once everybody has gcc >= 4.9.2
// template class arangodb::basics::DataProtector<64>;
int arangodb::basics::DataProtector::getMyId() {
int id = _mySlot;
if (id >= 0) {
return id;
}
while (true) {
int newId = _last + 1;
if (newId >= DATA_PROTECTOR_MULTIPLICITY) {
newId = 0;
}
if (_last.compare_exchange_strong(id, newId)) {
_mySlot = newId;
return newId;
}
}
}

View File

@ -146,22 +146,7 @@ class DataProtector {
_list[id]._count--; // this is implicitly using memory_order_seq_cst
}
int getMyId() {
int id = _mySlot;
if (id >= 0) {
return id;
}
while (true) {
int newId = _last + 1;
if (newId >= DATA_PROTECTOR_MULTIPLICITY) {
newId = 0;
}
if (_last.compare_exchange_strong(id, newId)) {
_mySlot = newId;
return newId;
}
}
}
int getMyId();
};
} // namespace arangodb::basics