Skip to content

Commit

Permalink
remove this_thread::yield
Browse files Browse the repository at this point in the history
  • Loading branch information
Naviabheeman committed Jun 20, 2023
1 parent cc7f9b1 commit fa463dd
Show file tree
Hide file tree
Showing 5 changed files with 0 additions and 18 deletions.
1 change: 0 additions & 1 deletion src/index/txindex.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,6 @@ bool TxIndex::DB::MigrateData(CBlockTreeDB& block_tree_db, const CBlockLocator&
bool interrupted = false;
std::unique_ptr<CDBIterator> cursor(block_tree_db.NewIterator());
for (cursor->Seek(begin_key); cursor->Valid(); cursor->Next()) {
std::this_thread::yield();;
if (ShutdownRequested()) {
interrupted = true;
break;
Expand Down
2 changes: 0 additions & 2 deletions src/rpc/blockchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -838,7 +838,6 @@ static bool GetUTXOStats(CCoinsView *view, CCoinsStats &stats)
uint256 prevkey;
std::map<uint32_t, Coin> outputs;
while (pcursor->Valid()) {
std::this_thread::yield();
COutPoint key;
Coin coin;
if (pcursor->GetKey(key) && pcursor->GetValue(coin)) {
Expand Down Expand Up @@ -1831,7 +1830,6 @@ bool FindScriptPubKey(std::atomic<int>& scan_progress, const std::atomic<bool>&
Coin coin;
if (!cursor->GetKey(key) || !cursor->GetValue(coin)) return false;
if (++count % 8192 == 0) {
std::this_thread::yield();
if (should_abort) {
// allow to abort the scan via the abort reference
return false;
Expand Down
2 changes: 0 additions & 2 deletions src/txdb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -278,7 +278,6 @@ bool CBlockTreeDB::LoadBlockIndexGuts(std::function<CBlockIndex*(const uint256&)

// Load mapBlockIndex
while (pcursor->Valid()) {
std::this_thread::yield();;
std::pair<char, uint256> key;
if (pcursor->GetKey(key) && key.first == DB_BLOCK_INDEX) {
CDiskBlockIndex diskindex;
Expand Down Expand Up @@ -389,7 +388,6 @@ bool CCoinsViewDB::Upgrade() {
std::pair<unsigned char, uint256> key;
std::pair<unsigned char, uint256> prev_key = {DB_COINS, uint256()};
while (pcursor->Valid()) {
std::this_thread::yield();;
if (ShutdownRequested()) {
break;
}
Expand Down
8 changes: 0 additions & 8 deletions src/validation.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2613,8 +2613,6 @@ bool CChainState::ActivateBestChain(CValidationState &state, std::shared_ptr<con
CBlockIndex *pindexNewTip = nullptr;
int nStopAtHeight = gArgs.GetArg("-stopatheight", DEFAULT_STOPATHEIGHT);
do {
std::this_thread::yield();;

if (GetMainSignals().CallbacksPending() > 10) {
// Block until the validation queue drains. This should largely
// never happen in normal operation, however may happen during
Expand Down Expand Up @@ -3680,8 +3678,6 @@ bool CChainState::LoadBlockIndex(CBlockTreeDB& blocktree)
if (!blocktree.LoadBlockIndexGuts([this](const uint256& hash) EXCLUSIVE_LOCKS_REQUIRED(cs_main) { return this->InsertBlockIndex(hash); }))
return false;

std::this_thread::yield();;

std::vector<std::pair<int, CBlockIndex*> > vSortedByHeight;
vSortedByHeight.reserve(mapBlockIndex.size());
for (const std::pair<const uint256, CBlockIndex*>& item : mapBlockIndex)
Expand Down Expand Up @@ -3840,7 +3836,6 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
int reportDone = 0;
LogPrintf("[0%%]..."); /* Continued */
for (pindex = chainActive.Tip(); pindex && pindex->pprev; pindex = pindex->pprev) {
std::this_thread::yield();;
int percentageDone = std::max(1, std::min(99, (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * (nCheckLevel >= 4 ? 50 : 100))));
if (reportDone < percentageDone/10) {
// report every 10% step
Expand Down Expand Up @@ -3898,7 +3893,6 @@ bool CVerifyDB::VerifyDB(CCoinsView *coinsview, int nCheckLevel, int nCheckDepth
// check level 4: try reconnecting blocks
if (nCheckLevel >= 4) {
while (pindex != chainActive.Tip()) {
std::this_thread::yield();;
uiInterface.ShowProgress(_("Verifying blocks..."), std::max(1, std::min(99, 100 - (int)(((double)(chainActive.Height() - pindex->nHeight)) / (double)nCheckDepth * 50))), false);
pindex = chainActive.Next(pindex);
CBlock block;
Expand Down Expand Up @@ -4186,8 +4180,6 @@ bool LoadExternalBlockFile(FILE* fileIn, CDiskBlockPos *dbp, CXFieldHistoryMap*
CBufferedFile blkdat(fileIn, 2*GetCurrentMaxBlockSize(), GetCurrentMaxBlockSize()+8, SER_DISK, CLIENT_VERSION);
uint64_t nRewind = blkdat.GetPos();
while (!blkdat.eof()) {
std::this_thread::yield();;

LogPrint(BCLog::REINDEX, "%s: nRewind : %d (%s out of order)\n", __func__, nRewind,
outOfOrder ? "after" : "before");
blkdat.SetPos(nRewind);
Expand Down
5 changes: 0 additions & 5 deletions src/wallet/db.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,6 @@ bool BerkeleyEnvironment::Open(bool retry)
if (fDbEnvInit)
return true;

std::this_thread::yield();;

fs::path pathIn = strPath;
TryCreateDirectories(pathIn);
if (!LockDirectory(pathIn, ".walletlock")) {
Expand Down Expand Up @@ -203,8 +201,6 @@ void BerkeleyEnvironment::MakeMock()
if (fDbEnvInit)
throw std::runtime_error("BerkeleyEnvironment::MakeMock: Already initialized");

std::this_thread::yield();;

LogPrint(BCLog::DB, "BerkeleyEnvironment::MakeMock\n");

dbenv->set_cachesize(1, 0, 1);
Expand Down Expand Up @@ -725,7 +721,6 @@ bool BerkeleyBatch::PeriodicFlush(BerkeleyDatabase& database)

if (nRefCount == 0)
{
std::this_thread::yield();;
std::map<std::string, int>::iterator mi = env->mapFileUseCount.find(strFile);
if (mi != env->mapFileUseCount.end())
{
Expand Down

0 comments on commit fa463dd

Please sign in to comment.