logic: reimplemented task system to abort ast visiting
* reimplemented interrupting TaskParseCxx by adding a listener for the MessageInterruptTask and returning a failure status code on update. This cancels the parent sequence task which results in the indexed items not getting inserted into the persistent storage * removed the capability for interrupting from TaskScheduler * changed task system to be closer to the standard behavior tree implementation * changed task system to accommodate the 3 status return types: Running, Success and Failure * made TaskGroupSequential fail once a member task fails * made TaskGroupParallel fail once a member task fails * split TaskParse... into one task for indexing and one task for injecting * added TaskRunner that handles updating and resetting the managed task * fixed numbers that are shown as parsed file count in indexing ui * fixed deadlock that originated from interaction between TaskScheduler and MessageQueue (one thread wanted to destroy a message listener on a task while the other one wanted to send as message as a task)
This commit is contained in:
@@ -260,24 +260,26 @@ void MessageQueue::sendMessageAsTask(std::shared_ptr<MessageBase> message, bool
|
||||
{
|
||||
std::shared_ptr<TaskGroupSequential> taskGroup = std::make_shared<TaskGroupSequential>();
|
||||
|
||||
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
||||
for (size_t i = 0; i < m_listeners.size(); i++)
|
||||
{
|
||||
MessageListenerBase* listener = m_listeners[i];
|
||||
|
||||
if (listener->getType() == message->getType())
|
||||
std::lock_guard<std::mutex> lock(m_listenersMutex);
|
||||
for (size_t i = 0; i < m_listeners.size(); i++)
|
||||
{
|
||||
uint listenerId = listener->getId();
|
||||
taskGroup->addTask(std::make_shared<TaskLambda>(
|
||||
[listenerId, message]()
|
||||
{
|
||||
MessageListenerBase* listener = MessageQueue::getInstance()->getListenerById(listenerId);
|
||||
if (listener)
|
||||
MessageListenerBase* listener = m_listeners[i];
|
||||
|
||||
if (listener->getType() == message->getType())
|
||||
{
|
||||
uint listenerId = listener->getId();
|
||||
taskGroup->addTask(std::make_shared<TaskLambda>(
|
||||
[listenerId, message]()
|
||||
{
|
||||
listener->handleMessageBase(message.get());
|
||||
MessageListenerBase* listener = MessageQueue::getInstance()->getListenerById(listenerId);
|
||||
if (listener)
|
||||
{
|
||||
listener->handleMessageBase(message.get());
|
||||
}
|
||||
}
|
||||
}
|
||||
));
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user