usbloadergx/source/utils/ThreadedTask.cpp
dimok321 6022ad060d *Added ThreadedTask instance class for easy one time run operations on another thread
*Added Free Space show option to the settings (can be enabled even on FAT partitions)
*Moved partition free space determination to a ThreadedTask because it takes up to 10 seconds on FAT. This speeds up the build up of the main game menu (on start and on change from other menu) on all partitions.
*Removed double "waiting for slow HDD" screens
*Fixed scrollbar in settings
2010-12-31 13:13:14 +00:00

37 lines
827 B
C++

#include "ThreadedTask.hpp"
ThreadedTask * ThreadedTask::instance = NULL;
ThreadedTask::ThreadedTask()
: ExitRequested(false)
{
LWP_CreateThread (&Thread, ThreadCallback, this, NULL, 16384, 80);
}
ThreadedTask::~ThreadedTask()
{
ExitRequested = true;
Execute();
LWP_JoinThread(Thread, NULL);
}
void * ThreadedTask::ThreadCallback(void *arg)
{
ThreadedTask * myInstance = (ThreadedTask *) arg;
while(!myInstance->ExitRequested)
{
LWP_SuspendThread(myInstance->Thread);
while(!myInstance->CallbackList.empty())
{
myInstance->CallbackList[0]->Execute(myInstance->ArgList[0]);
myInstance->CallbackList.erase(myInstance->CallbackList.begin());
myInstance->ArgList.erase(myInstance->ArgList.begin());
}
}
return NULL;
}