src/worker.cc
// Memory invert work loop. Execute until marked done.
Memory invert work loop. Execute until marked done.
Memory invert work loop . Execute until marked done .
bool InvertThread::Work() {
  struct page_entry src;
  bool result = true;
  int64 loops = 0;
  logprintf(9, "Log: Starting invert thread %d\n", thread_num_);
  while (IsReadyToRun()) {
    result = result && sat_->GetValid(&src);
    if (!result) {
      logprintf(0, "Process Error: invert_thread failed to pop pages, "
                "bailing\n");
      break;
    }
    if (sat_->strict())
      CrcCheckPage(&src);
    InvertPageUp(&src);
    YieldSelf();
    InvertPageDown(&src);
    YieldSelf();
    InvertPageDown(&src);
    YieldSelf();
    InvertPageUp(&src);
    YieldSelf();
    if (sat_->strict())
      CrcCheckPage(&src);
    result = result && sat_->PutValid(&src);
    if (!result) {
      logprintf(0, "Process Error: invert_thread failed to push pages, "
                "bailing\n");
      break;
    }
    loops++;
  }
  pages_copied_ = loops * 2;
  status_ = result;
  logprintf(9, "Log: Completed %d: Copy thread. Status %d, %d pages copied\n",
            thread_num_, status_, pages_copied_);
  return result;
}
bool InvertThread :: Work ( ) { struct page_entry src ; bool result = true ; int64 loops = 0 ; logprintf ( 9 , " \n " , thread_num_ ) ; while ( IsReadyToRun ( ) ) { result = result && sat_ -> GetValid ( & src ) ; if ( ! result ) { logprintf ( 0 , " " " \n " ) ; break ; } if ( sat_ -> strict ( ) ) CrcCheckPage ( & src ) ; InvertPageUp ( & src ) ; YieldSelf ( ) ; InvertPageDown ( & src ) ; YieldSelf ( ) ; InvertPageDown ( & src ) ; YieldSelf ( ) ; InvertPageUp ( & src ) ; YieldSelf ( ) ; if ( sat_ -> strict ( ) ) CrcCheckPage ( & src ) ; result = result && sat_ -> PutValid ( & src ) ; if ( ! result ) { logprintf ( 0 , " " " \n " ) ; break ; } loops ++ ; } pages_copied_ = loops * 2 ; status_ = result ; logprintf ( 9 , " \n " , thread_num_ , status_ , pages_copied_ ) ; return result ; }
Memory invert work loop.
Memory invert work loop .
// Pop the needed pages. // For the same reason CopyThread yields itself (see YieldSelf comment // in CopyThread::Work(), InvertThread yields itself after each invert // operation to improve cooperation between different worker threads // stressing the memory/cache.