src/backend/common/epoch.cpp
// Helper Function for cleaning from @param clean_from_epoch to @param
// clean_till_epoch
Helper Function for cleaning from @param clean_from_epoch to @param
clean_till_epoch
Helper Function for cleaning from @param clean_from_epoch to @param clean_till_epoch
bool Epoch::GCHelper(oid_t clean_from_epoch, oid_t clean_till_epoch) {
  bool retval = false;
  auto &txn_manager = concurrency::TransactionManagerFactory::GetInstance();
  auto &gc_manager = gc::GCManagerFactory::GetInstance();
  if (txn_manager.PerformEpochCAS(clean_from_epoch, clean_till_epoch)) {
    for (; clean_from_epoch < clean_till_epoch; clean_from_epoch++) {
      Epoch *e = txn_manager.GetEpoch(clean_from_epoch);
      if (e == nullptr) {
        continue;
      }
      gc_manager.PerformGC(e);
      txn_manager.EraseEpoch(clean_from_epoch);
      if (e != this) {
        delete e;
      } else {
        retval = true;
      }
    }
    return retval;
  } else {
    return retval;
  }
}
bool Epoch :: GCHelper ( oid_t clean_from_epoch , oid_t clean_till_epoch ) { bool retval = false ; auto & txn_manager = concurrency :: TransactionManagerFactory :: GetInstance ( ) ; auto & gc_manager = gc :: GCManagerFactory :: GetInstance ( ) ; if ( txn_manager . PerformEpochCAS ( clean_from_epoch , clean_till_epoch ) ) { for ( ; clean_from_epoch < clean_till_epoch ; clean_from_epoch ++ ) { Epoch * e = txn_manager . GetEpoch ( clean_from_epoch ) ; if ( e == nullptr ) { continue ; } gc_manager . PerformGC ( e ) ; txn_manager . EraseEpoch ( clean_from_epoch ) ; if ( e != this ) { delete e ; } else { retval = true ; } } return retval ; } else { return retval ; } }
Helper Function for cleaning from @param clean_from_epoch to @param
clean_till_epoch
Helper Function for cleaning from @param clean_from_epoch to @param clean_till_epoch
// Perform CAS on the smallest epoch. This ensures that only one // thread (the one that wins the CAS) cleans one epoch // iterate through all the epochs from smallest to largest and clean // them // if cleaned some epoch other than self, clean it // if cleaned self, signal the calling function (EndTransaction) using // retval // the calling function will delete the epoch in that case // lost the CAS, simply return