2016-01-18 15:33:29 +00:00
|
|
|
// 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);
|
2015-04-06 16:13:07 +00:00
|
|
|
while (m_asyncContexts > 0)
|
2014-06-25 17:21:42 +00:00
|
|
|
m_cv.wait(lock);
|
|
|
|
}
|
|
|
|
|
|
|
|
} //namespace CryptoNote
|