Skip to content

Commit

Permalink
Remove ILongRunningOperation and related code
Browse files Browse the repository at this point in the history
Looks like nothing is using this any more.
  • Loading branch information
Matthew Mott committed Feb 13, 2019
1 parent 772506f commit 330a6a3
Show file tree
Hide file tree
Showing 7 changed files with 4 additions and 125 deletions.
22 changes: 0 additions & 22 deletions include/iradiant.h
Expand Up @@ -9,20 +9,6 @@ const std::string MODULE_RADIANT("Radiant");

class ThreadManager;

// Interface to provide feedback during running operations
// see IRadiant::performLongRunningOperation()
class ILongRunningOperation
{
public:
virtual ~ILongRunningOperation() {}

// Update the operation progress fraction - range [0..1]
virtual void setProgress(float progress) = 0;

// Set the message that is displayed to the user
virtual void setMessage(const std::string& message) = 0;
};

/**
* \brief
* Interface to the core application.
Expand All @@ -40,14 +26,6 @@ class IRadiant :

/// Get the threading manager
virtual ThreadManager& getThreadManager() = 0;

// Runs a long running operation that should block input on all windows
// until it completes. The operation functor needs to take a reference to
// an operation object which can be used to give feedback like progress or
// text messages that might be displayed to the user.
virtual void performLongRunningOperation(
const std::function<void(ILongRunningOperation&)>& operationFunc,
const std::string& title = std::string()) = 0;
};

inline IRadiant& GlobalRadiant()
Expand Down
78 changes: 0 additions & 78 deletions radiant/RadiantModule.cpp
Expand Up @@ -49,84 +49,6 @@ ThreadManager& RadiantModule::getThreadManager()
return *_threadManager;
}

namespace
{

class LongRunningOperation :
public ILongRunningOperation,
private ui::ScreenUpdateBlocker
{
private:
bool _messageChanged;
std::string _message;

public:
LongRunningOperation(const std::string& title, const std::string& message) :
ScreenUpdateBlocker(title, message),
_messageChanged(true),
_message(message)
{}

void pulse()
{
ScreenUpdateBlocker::pulse();
}

void setProgress(float progress)
{
ScreenUpdateBlocker::setProgress(progress);
}

// Set the message that is displayed to the user
void setMessage(const std::string& message)
{
_message = message;
_messageChanged = true;
}

bool messageChanged()
{
return _messageChanged;
}

void dispatch()
{
_messageChanged = false;

ScreenUpdateBlocker::setMessage(_message);
}
};

}

void RadiantModule::performLongRunningOperation(
const std::function<void(ILongRunningOperation&)>& operationFunc,
const std::string& message)
{
LongRunningOperation operation(_("Processing..."), message);

std::size_t threadId = getThreadManager().execute([&]()
{
operationFunc(operation);
});

while (getThreadManager().threadIsRunning(threadId))
{
operation.pulse();

if (operation.messageChanged())
{
operation.dispatch();
}

wxTheApp->Yield();

wxThread::Sleep(15); // sleep for a few ms, then ask again
}

GlobalMainFrame().updateAllWindows();
}

void RadiantModule::broadcastShutdownEvent()
{
_threadManager.reset();
Expand Down
3 changes: 0 additions & 3 deletions radiant/RadiantModule.h
Expand Up @@ -32,9 +32,6 @@ class RadiantModule :
sigc::signal<void> signal_radiantShutdown() const override;

ThreadManager& getThreadManager() override;
void performLongRunningOperation(
const std::function<void(ILongRunningOperation&)>& operationFunc,
const std::string& title) override;

// RegisterableModule implementation
const std::string& getName() const override;
Expand Down
5 changes: 2 additions & 3 deletions radiant/shaders/Doom3ShaderSystem.cpp
Expand Up @@ -46,8 +46,7 @@ namespace shaders
Doom3ShaderSystem::Doom3ShaderSystem() :
_defLoader(std::bind(&Doom3ShaderSystem::loadMaterialFiles, this)),
_enableActiveUpdates(true),
_realised(false),
_currentOperation(nullptr)
_realised(false)
{}

void Doom3ShaderSystem::construct()
Expand Down Expand Up @@ -97,7 +96,7 @@ ShaderLibraryPtr Doom3ShaderSystem::loadMaterialFiles()
ShaderLibraryPtr library = std::make_shared<ShaderLibrary>();

// Load each file from the global filesystem
ShaderFileLoader loader(sPath, *library, _currentOperation);
ShaderFileLoader loader(sPath, *library);
{
ScopedDebugTimer timer("ShaderFiles parsed: ");
GlobalFileSystem().forEachFile(
Expand Down
3 changes: 0 additions & 3 deletions radiant/shaders/Doom3ShaderSystem.h
Expand Up @@ -47,9 +47,6 @@ class Doom3ShaderSystem :
sigc::signal<void> _signalDefsLoaded;
sigc::signal<void> _signalDefsUnloaded;

// Used to provide feedback to the user during long operations
ILongRunningOperation* _currentOperation;

public:

// Constructor, allocates the library
Expand Down
8 changes: 0 additions & 8 deletions radiant/shaders/ShaderFileLoader.cpp
Expand Up @@ -90,14 +90,6 @@ void ShaderFileLoader::parseFiles()
{
const std::string& fullPath = _files[i];

if (_currentOperation)
{
_currentOperation->setMessage(fmt::format(_("Parsing material file {0}"), fullPath));

float progress = static_cast<float>(i) / _files.size();
_currentOperation->setProgress(progress);
}

// Open the file
ArchiveTextFilePtr file = GlobalFileSystem().openTextFile(fullPath);

Expand Down
10 changes: 2 additions & 8 deletions radiant/shaders/ShaderFileLoader.h
Expand Up @@ -24,8 +24,6 @@ class ShaderFileLoader

ShaderLibrary& _library;

ILongRunningOperation* _currentOperation;

std::vector<std::string> _files;

private:
Expand All @@ -35,12 +33,8 @@ class ShaderFileLoader

public:
// Constructor. Set the basepath to prepend onto shader filenames.
ShaderFileLoader(const std::string& path,
ShaderLibrary& library,
ILongRunningOperation* currentOperation) :
_basePath(path),
_library(library),
_currentOperation(currentOperation)
ShaderFileLoader(const std::string& path, ShaderLibrary& library)
: _basePath(path), _library(library)
{
_files.reserve(200);
}
Expand Down

0 comments on commit 330a6a3

Please sign in to comment.