use std::function in Thread_Create so we can revert back to using it

This commit is contained in:
RSDuck 2021-02-11 16:00:36 +01:00
parent d63f7977f8
commit f05bc50d40
4 changed files with 8 additions and 10 deletions

View File

@ -37,10 +37,8 @@ void SoftRenderer::StopRenderThread()
{
RenderThreadRunning = false;
Platform::Semaphore_Post(Sema_RenderStart);
// Platform::Thread_Wait(RenderThread);
// Platform::Thread_Free(RenderThread);
RenderThread.join();
Platform::Thread_Wait(RenderThread);
Platform::Thread_Free(RenderThread);
}
}
@ -51,8 +49,7 @@ void SoftRenderer::SetupRenderThread()
if (!RenderThreadRunning)
{
RenderThreadRunning = true;
//RenderThread = Platform::Thread_Create(RenderThreadFunc);
RenderThread = std::thread(&SoftRenderer::RenderThreadFunc, this);
RenderThread = Platform::Thread_Create(std::bind(&RenderThreadFunc, this));
}
// otherwise more than one frame can be queued up at once

View File

@ -505,8 +505,7 @@ private:
// threading
bool Threaded;
// Platform::Thread* RenderThread;
std::thread RenderThread;
Platform::Thread* RenderThread;
bool RenderThreadRunning;
bool RenderThreadRendering;
Platform::Semaphore* Sema_RenderStart;

View File

@ -21,6 +21,8 @@
#include "types.h"
#include <functional>
namespace Platform
{
@ -68,7 +70,7 @@ inline bool LocalFileExists(const char* name)
}
struct Thread;
Thread* Thread_Create(void (*func)());
Thread* Thread_Create(std::function<void()> func);
void Thread_Free(Thread* thread);
void Thread_Wait(Thread* thread);

View File

@ -188,7 +188,7 @@ FILE* OpenLocalFile(const char* path, const char* mode)
return OpenFile(fullpath.toUtf8(), mode, mode[0] != 'w');
}
Thread* Thread_Create(void (* func)())
Thread* Thread_Create(std::function<void()> func)
{
QThread* t = QThread::create(func);
t->start();