30 lines
732 B
C++
30 lines
732 B
C++
|
// Copyright (c) 2012-2013 The Cryptonote developers
|
||
|
// 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)
|
||
|
m_cv.wait(lock);
|
||
|
}
|
||
|
|
||
|
} //namespace CryptoNote
|
||
|
|
||
|
|