1
0
Fork 0

Merge branch 'devel' of github.com:arangodb/arangodb into devel

This commit is contained in:
Michael Hackstein 2017-04-28 14:13:58 +02:00
commit fef0528b95
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