first attempt at threading the 3D renderer

This commit is contained in:
StapleButter
2017-05-23 23:38:28 +02:00
parent 88d982b7e3
commit 4b3caedbe7
7 changed files with 176 additions and 405 deletions

View File

@ -21,6 +21,11 @@
#include <string.h>
#include "../Platform.h"
#include <wx/wxprec.h>
#ifndef WX_PRECOMP
#include <wx/wx.h>
#endif
#ifdef __WXMSW__
#include <winsock2.h>
#include <ws2tcpip.h>
@ -46,6 +51,29 @@ namespace Platform
{
class Thread : public wxThread
{
public:
Thread(void (*func)())
: wxThread(wxTHREAD_JOINABLE)
{
this->Func = func;
}
~Thread() {}
protected:
virtual ExitCode Entry()
{
Func();
return (ExitCode)0;
}
private:
void (*Func)();
};
socket_t MPSocket;
sockaddr_t MPSendAddr;
u8 PacketBuffer[2048];
@ -53,6 +81,45 @@ u8 PacketBuffer[2048];
#define NIFI_VER 1
void* Thread_Create(void (*func)())
{
Thread* ret = new Thread(func);
ret->Run();
return (void*)ret;
}
void Thread_Free(void* thread)
{
delete (Thread*)thread;
}
void Thread_Wait(void* thread)
{
((Thread*)thread)->Wait();
}
void* Semaphore_Create()
{
return (void*)new wxSemaphore();
}
void Semaphore_Free(void* sema)
{
delete (wxSemaphore*)sema;
}
void Semaphore_Wait(void* sema)
{
((wxSemaphore*)sema)->Wait();
}
void Semaphore_Post(void* sema)
{
((wxSemaphore*)sema)->Post();
}
bool MP_Init()
{
int opt_true = 1;