voidDBImpl::WaitForBackgroundWork(){ // Wait for background work to finish while (bg_bottom_compaction_scheduled_ || bg_compaction_scheduled_ || bg_flush_scheduled_) { bg_cv_.Wait(); } }
voidwait_for_background_work(rocksdb::DB *db){ while (1) { if (has_background_work(db)) { std::this_thread::sleep_for(std::chrono::seconds(1)); continue; } // The properties are not get atomically. Test for more 20 times. int i; for (i = 0; i < 20; ++i) { std::this_thread::sleep_for(std::chrono::milliseconds(100)); if (has_background_work(db)) { break; } } if (i == 20) { std::cout << "There is no background work detected for more than 2 seconds. Exiting...\n"; break; } } }