void N::insertGrow(curN *n, uint64_t v, N *parentNode, uint64_t parentVersion, uint8_t keyParent, uint8_t key, N *val, bool &needRestart, ThreadInfo &threadInfo) { if (!n->isFull()) { if (parentNode != nullptr) { parentNode->readUnlockOrRestart(parentVersion, needRestart); if (needRestart) return; } n->upgradeToWriteLockOrRestart(v, needRestart); if (needRestart) return; n->insert(key, val); n->writeUnlock(); return; } parentNode->upgradeToWriteLockOrRestart(parentVersion, needRestart); if (needRestart) return; n->upgradeToWriteLockOrRestart(v, needRestart); if (needRestart) { parentNode->writeUnlock(); return; } auto nBig = new biggerN(n->getPrefix(), n->getPrefixLength()); n->copyTo(nBig); nBig->insert(key, val); N::change(parentNode, keyParent, nBig); n->writeUnlockObsolete(); threadInfo.getEpoche().markNodeForDeletion(n, threadInfo); parentNode->writeUnlock(); }
void N::removeAndShrink(curN *n, uint64_t v, N *parentNode, uint64_t parentVersion, uint8_t keyParent, uint8_t key, bool &needRestart, ThreadInfo &threadInfo) { if (!n->isUnderfull() || parentNode == nullptr) { if (parentNode != nullptr) { parentNode->readUnlockOrRestart(parentVersion, needRestart); if (needRestart) return; } n->upgradeToWriteLockOrRestart(v, needRestart); if (needRestart) return; n->remove(key); n->writeUnlock(); return; } parentNode->upgradeToWriteLockOrRestart(parentVersion, needRestart); if (needRestart) return; n->upgradeToWriteLockOrRestart(v, needRestart); if (needRestart) { parentNode->writeUnlock(); return; } auto nSmall = new smallerN(n->getPrefix(), n->getPrefixLength()); n->copyTo(nSmall); nSmall->remove(key); N::change(parentNode, keyParent, nSmall); n->writeUnlockObsolete(); threadInfo.getEpoche().markNodeForDeletion(n, threadInfo); parentNode->writeUnlock(); }
EpocheGuard(ThreadInfo<Key, Data> &threadEpocheInfo) : threadEpocheInfo(threadEpocheInfo) { threadEpocheInfo.getEpoche().enterEpoche(threadEpocheInfo); }