forked from organicmaps/organicmaps
support for cancellation notification.
This commit is contained in:
parent
fa1710c108
commit
93d55761b6
2 changed files with 20 additions and 0 deletions
|
@ -79,6 +79,13 @@ namespace core
|
|||
void CommandsQueue::Routine::Cancel()
|
||||
{
|
||||
m_env.Cancel();
|
||||
|
||||
// performing cancellation tasks
|
||||
for(list<Command>::const_iterator it = m_parent->m_cancelCommands.begin();
|
||||
it != m_parent->m_cancelCommands.end();
|
||||
++it)
|
||||
it->m_fn(m_env);
|
||||
|
||||
IRoutine::Cancel();
|
||||
}
|
||||
|
||||
|
@ -138,6 +145,11 @@ namespace core
|
|||
m_finCommands.push_back(cmd);
|
||||
}
|
||||
|
||||
void CommandsQueue::AddCancelCommand(Command const & cmd)
|
||||
{
|
||||
m_cancelCommands.push_back(cmd);
|
||||
}
|
||||
|
||||
void CommandsQueue::Clear()
|
||||
{
|
||||
threads::ConditionGuard g(m_cond);
|
||||
|
|
|
@ -113,6 +113,7 @@ namespace core
|
|||
|
||||
list<Command> m_initCommands;
|
||||
list<Command> m_finCommands;
|
||||
list<Command> m_cancelCommands;
|
||||
|
||||
friend class Routine;
|
||||
|
||||
|
@ -132,6 +133,7 @@ namespace core
|
|||
void AddCommand(Command const & cmd);
|
||||
void AddInitCommand(Command const & cmd);
|
||||
void AddFinCommand(Command const & cmd);
|
||||
void AddCancelCommand(Command const & cmd);
|
||||
void Start();
|
||||
void Clear();
|
||||
void Cancel();
|
||||
|
@ -155,5 +157,11 @@ namespace core
|
|||
AddFinCommand(Command(m_cmdId++, cmd));
|
||||
}
|
||||
|
||||
template <typename command_tt>
|
||||
void AddCancelCommand(command_tt cmd)
|
||||
{
|
||||
AddCancelCommand(Command(m_cmdId++, cmd));
|
||||
}
|
||||
|
||||
};
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue