mirror of
https://github.com/wownero/wownero-cpp.git
synced 2026-10-20 08:38:41 +02:00
replace sync_loop_func() with lambda
This commit is contained in:
@@ -3308,31 +3308,27 @@ namespace monero {
|
||||
|
||||
// start sync loop thread
|
||||
m_syncing_thread = boost::thread([this]() {
|
||||
this->sync_loop_func();
|
||||
|
||||
// sync while enabled
|
||||
while (m_syncing_enabled) {
|
||||
try {
|
||||
lock_and_sync();
|
||||
} catch (...) {
|
||||
cout << "monero_wallet_core failed to background synchronize" << endl;
|
||||
}
|
||||
|
||||
// only wait if syncing still enabled
|
||||
if (m_syncing_enabled) {
|
||||
boost::mutex::scoped_lock lock(m_syncing_mutex);
|
||||
boost::posix_time::milliseconds wait_for_ms(m_syncing_interval.load());
|
||||
m_sync_cv.timed_wait(lock, wait_for_ms);
|
||||
}
|
||||
}
|
||||
|
||||
m_sync_loop_running = false;
|
||||
});
|
||||
}
|
||||
|
||||
void monero_wallet_core::sync_loop_func() {
|
||||
|
||||
// sync while enabled
|
||||
while (m_syncing_enabled) {
|
||||
try {
|
||||
lock_and_sync();
|
||||
} catch (...) {
|
||||
cout << "monero_wallet_core failed to background synchronize" << endl;
|
||||
}
|
||||
|
||||
// only wait if syncing still enabled
|
||||
if (m_syncing_enabled) {
|
||||
boost::mutex::scoped_lock lock(m_syncing_mutex);
|
||||
boost::posix_time::milliseconds wait_for_ms(m_syncing_interval.load());
|
||||
m_sync_cv.timed_wait(lock, wait_for_ms);
|
||||
}
|
||||
}
|
||||
|
||||
m_sync_loop_running = false;
|
||||
}
|
||||
|
||||
monero_sync_result monero_wallet_core::lock_and_sync(boost::optional<uint64_t> start_height) {
|
||||
bool rescan = m_rescan_on_sync.exchange(false);
|
||||
boost::lock_guard<boost::mutex> guarg(m_sync_mutex); // synchronize sync() and syncAsync()
|
||||
|
||||
@@ -316,7 +316,6 @@ namespace monero {
|
||||
boost::thread m_syncing_thread; // thread for auto sync loop
|
||||
boost::mutex m_syncing_mutex; // synchronize auto sync loop
|
||||
void run_sync_loop(); // run the sync loop in a thread
|
||||
void sync_loop_func(); // function to run thread with syncing loop
|
||||
monero_sync_result lock_and_sync(boost::optional<uint64_t> start_height = boost::none); // internal function to synchronize request to sync and rescan
|
||||
monero_sync_result sync_aux(boost::optional<uint64_t> start_height = boost::none); // internal function to immediately block, sync, and report progress
|
||||
};
|
||||
|
||||
Reference in New Issue
Block a user