mirror of
https://github.com/monero-project/monero.git
synced 2025-08-09 19:22:21 -04:00
wallet: cancellable refresh
^C while in manual refresh will cancel the refresh, since that's often an annoying thing to have to wait for. Also, a manual refresh command will interrupt any running background refresh and take over, rather than wait for the background refresh to be done, and look to be hanging.
This commit is contained in:
parent
8289975e22
commit
d68a63e404
5 changed files with 58 additions and 14 deletions
|
@ -130,7 +130,7 @@ namespace tools
|
|||
{
|
||||
if (CTRL_C_EVENT == type || CTRL_BREAK_EVENT == type)
|
||||
{
|
||||
handle_signal();
|
||||
handle_signal(type);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -141,21 +141,21 @@ namespace tools
|
|||
}
|
||||
#else
|
||||
/*! \brief handler for NIX */
|
||||
static void posix_handler(int /*type*/)
|
||||
static void posix_handler(int type)
|
||||
{
|
||||
handle_signal();
|
||||
handle_signal(type);
|
||||
}
|
||||
#endif
|
||||
|
||||
/*! \brief calles m_handler */
|
||||
static void handle_signal()
|
||||
static void handle_signal(int type)
|
||||
{
|
||||
static std::mutex m_mutex;
|
||||
std::unique_lock<std::mutex> lock(m_mutex);
|
||||
m_handler();
|
||||
m_handler(type);
|
||||
}
|
||||
|
||||
/*! \brief where the installed handler is stored */
|
||||
static std::function<void(void)> m_handler;
|
||||
static std::function<void(int)> m_handler;
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue