utility: Sending Messages via TaskScheduler by default
This change makes the MessageQueue use Tasks for sending a Message to each MessageListener. Messages can define their behavior by setting setSendAsTask(), the default is true. Only MessageStatus and MessageInterruptTasks are still sent on the Messaging thread to allow for immediate effect. This change also introduced the class SimpleTask which holds only a single perform() callback to override, for Tasks that are finished in a single step. The class LambdaTask derives from SimpleTask and allows for passing a lambda as the perform() callback.
This commit is contained in:
@@ -1,19 +1,10 @@
|
||||
#include "component/controller/StatusBarController.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <iomanip>
|
||||
|
||||
#include "utility/logging/logging.h"
|
||||
|
||||
#include "component/view/StatusBarView.h"
|
||||
|
||||
StatusBarController::StatusBarController()
|
||||
: MessageListener<MessageError>(true)
|
||||
, MessageListener<MessageFinishedParsing>(true)
|
||||
, MessageListener<MessageLoadProject>(true)
|
||||
, MessageListener<MessageLoadSource>(true)
|
||||
, MessageListener<MessageRefresh>(true)
|
||||
, MessageListener<MessageStatus>(true)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -26,42 +17,9 @@ StatusBarView* StatusBarController::getView()
|
||||
return Controller::getView<StatusBarView>();
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageFinishedParsing* message)
|
||||
{
|
||||
std::stringstream ss;
|
||||
ss << "Parsing Finished: ";
|
||||
ss << message->fileCount << "/" << message->totalFileCount << " files, ";
|
||||
ss << std::setprecision(2) << std::fixed << message->parseTime << " seconds, ";
|
||||
ss << message->errorCount << " error(s)";
|
||||
|
||||
bool hasErrors = message->errorCount > 0;
|
||||
|
||||
setStatus(ss.str(), hasErrors);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageStatus* message)
|
||||
{
|
||||
setStatus(message->status);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageError* message)
|
||||
{
|
||||
setStatus(message->error, true);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageLoadProject* message)
|
||||
{
|
||||
setStatus("Loading Project: " + message->projectSettingsFilePath);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageLoadSource* message)
|
||||
{
|
||||
setStatus("Loading Source: " + message->sourceDirectoryPath);
|
||||
}
|
||||
|
||||
void StatusBarController::handleMessage(MessageRefresh* message)
|
||||
{
|
||||
setStatus("Refreshing Project");
|
||||
setStatus(message->status, message->isError);
|
||||
}
|
||||
|
||||
void StatusBarController::setStatus(const std::string& status, bool isError)
|
||||
|
||||
Reference in New Issue
Block a user