danicoin/src/Wallet/WalletAsyncContextCounter.cpp

28 lines
734 B
C++
Raw Normal View History

// Copyright (c) 2011-2016 The Cryptonote developers
2014-06-25 17:21:42 +00:00
// Distributed under the MIT/X11 software license, see the accompanying
// file COPYING or http://www.opensource.org/licenses/mit-license.php.
#include "WalletAsyncContextCounter.h"
namespace CryptoNote {
void WalletAsyncContextCounter::addAsyncContext() {
std::unique_lock<std::mutex> lock(m_mutex);
m_asyncContexts++;
}
void WalletAsyncContextCounter::delAsyncContext() {
std::unique_lock<std::mutex> lock(m_mutex);
m_asyncContexts--;
if (!m_asyncContexts) m_cv.notify_one();
}
void WalletAsyncContextCounter::waitAsyncContextsFinish() {
std::unique_lock<std::mutex> lock(m_mutex);
while (m_asyncContexts > 0)
2014-06-25 17:21:42 +00:00
m_cv.wait(lock);
}
} //namespace CryptoNote