[monero-project/monero] simplewallet: Simplify LOCK_IDLE_SCOPE macro (#4249)

rbrunner7 commented on this pull request.

> boost::unique_lock lock(m_idle_mutex); \
— epee::misc_utils::auto_scope_leave_caller scope_exit_handler = epee::misc_utils::create_scope_leave_handler([&](){ \
— m_auto_refresh_enabled.store(auto_refresh_enabled, std::memory_order_relaxed); \
— })
+ m_idle_cond.notify_one();

Nothing. Nothing bad would happen, though, as far as I can see; just one more autorefresh would squeeze in and unstop the wallet. And no change compared with the status quo in this regard.

But, now that you point this out, I realize that of course it makes more sense to lock **first** and only then call `stop` because that is a state change of the wallet that probably should not happen if one does not currently «own» the wallet.

I will switch the order of those 2 lines.

Currently the only thing within `wallet2` that reacts to such a «stopping» is a running refresh loop that can’t run anymore anyway in the current constellation of simplewallet’s threads after one has a lock on the mutex (everybody only refreshes under the protection of a lock), so right now that call does nothing if done after locking.

But of course that could change in the future. Maybe in the future there will also be a need for a way for the wallet to signal back «I am really stopped now», because that may take some time after all.

Добавить комментарий