mirror of
https://github.com/monero-project/monero.git
synced 2024-10-01 11:49:47 -04:00
switch wallet API from std thread/mutex to boost
This commit is contained in:
parent
c45595a02e
commit
8a274eab3f
@ -170,7 +170,7 @@ WalletImpl::WalletImpl(bool testnet)
|
|||||||
m_refreshThreadDone = false;
|
m_refreshThreadDone = false;
|
||||||
m_refreshEnabled = false;
|
m_refreshEnabled = false;
|
||||||
m_refreshIntervalSeconds = DEFAULT_REFRESH_INTERVAL_SECONDS;
|
m_refreshIntervalSeconds = DEFAULT_REFRESH_INTERVAL_SECONDS;
|
||||||
m_refreshThread = std::thread([this] () {
|
m_refreshThread = boost::thread([this] () {
|
||||||
this->refreshThreadFunc();
|
this->refreshThreadFunc();
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -632,12 +632,12 @@ void WalletImpl::refreshThreadFunc()
|
|||||||
LOG_PRINT_L3(__FUNCTION__ << ": starting refresh thread");
|
LOG_PRINT_L3(__FUNCTION__ << ": starting refresh thread");
|
||||||
|
|
||||||
while (true) {
|
while (true) {
|
||||||
std::unique_lock<std::mutex> lock(m_refreshMutex);
|
boost::mutex::scoped_lock lock(m_refreshMutex);
|
||||||
if (m_refreshThreadDone) {
|
if (m_refreshThreadDone) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": waiting for refresh...");
|
LOG_PRINT_L3(__FUNCTION__ << ": waiting for refresh...");
|
||||||
m_refreshCV.wait_for(lock, std::chrono::seconds(m_refreshIntervalSeconds));
|
m_refreshCV.wait(lock);
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired...");
|
LOG_PRINT_L3(__FUNCTION__ << ": refresh lock acquired...");
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled);
|
LOG_PRINT_L3(__FUNCTION__ << ": m_refreshEnabled: " << m_refreshEnabled);
|
||||||
LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << m_status);
|
LOG_PRINT_L3(__FUNCTION__ << ": m_status: " << m_status);
|
||||||
@ -652,7 +652,7 @@ void WalletImpl::refreshThreadFunc()
|
|||||||
void WalletImpl::doRefresh()
|
void WalletImpl::doRefresh()
|
||||||
{
|
{
|
||||||
// synchronizing async and sync refresh calls
|
// synchronizing async and sync refresh calls
|
||||||
std::lock_guard<std::mutex> guarg(m_refreshMutex2);
|
boost::lock_guard<boost::mutex> guarg(m_refreshMutex2);
|
||||||
try {
|
try {
|
||||||
m_wallet->refresh();
|
m_wallet->refresh();
|
||||||
} catch (const std::exception &e) {
|
} catch (const std::exception &e) {
|
||||||
|
@ -35,9 +35,9 @@
|
|||||||
#include "wallet/wallet2.h"
|
#include "wallet/wallet2.h"
|
||||||
|
|
||||||
#include <string>
|
#include <string>
|
||||||
#include <thread>
|
#include <boost/thread/mutex.hpp>
|
||||||
#include <mutex>
|
#include <boost/thread/thread.hpp>
|
||||||
#include <condition_variable>
|
#include <boost/thread/condition_variable.hpp>
|
||||||
|
|
||||||
|
|
||||||
namespace Bitmonero {
|
namespace Bitmonero {
|
||||||
@ -113,12 +113,12 @@ private:
|
|||||||
std::atomic<bool> m_refreshThreadDone;
|
std::atomic<bool> m_refreshThreadDone;
|
||||||
std::atomic<int> m_refreshIntervalSeconds;
|
std::atomic<int> m_refreshIntervalSeconds;
|
||||||
// synchronizing refresh loop;
|
// synchronizing refresh loop;
|
||||||
std::mutex m_refreshMutex;
|
boost::mutex m_refreshMutex;
|
||||||
|
|
||||||
// synchronizing sync and async refresh
|
// synchronizing sync and async refresh
|
||||||
std::mutex m_refreshMutex2;
|
boost::mutex m_refreshMutex2;
|
||||||
std::condition_variable m_refreshCV;
|
boost::condition_variable m_refreshCV;
|
||||||
std::thread m_refreshThread;
|
boost::thread m_refreshThread;
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user