replace pthread with mp_thread

This commit is contained in:
Reuben Dunnington 2023-07-30 21:35:08 -07:00
parent 93acffa277
commit b9bd2723a9
Signed by: rdunnington
GPG Key ID: 4EC5290E704FD482
3 changed files with 10 additions and 16 deletions

View File

@ -28,12 +28,9 @@ if %target% == milepost (
if %target% == orca ( if %target% == orca (
echo building orca echo building orca
set pthread_dir=..\vcpkg\packages\pthreads_x64-windows
::copy libraries ::copy libraries
copy milepost\bin\milepost.dll bin copy milepost\bin\milepost.dll bin
copy milepost\bin\milepost.dll.lib bin copy milepost\bin\milepost.dll.lib bin
copy %pthread_dir%\bin\pthreadVC3.dll bin
::generate wasm3 api bindings ::generate wasm3 api bindings
python3 scripts\bindgen.py core src\core_api.json^ python3 scripts\bindgen.py core src\core_api.json^
@ -58,8 +55,8 @@ if %target% == orca (
--wasm3-bindings src\io_api_bind_gen.c --wasm3-bindings src\io_api_bind_gen.c
::compile orca ::compile orca
set INCLUDES=/I src /I sdk /I ext\wasm3\source /I milepost\src /I milepost\ext /I %pthread_dir%\include set INCLUDES=/I src /I sdk /I ext\wasm3\source /I milepost\src /I milepost\ext
set LIBS=/LIBPATH:bin /LIBPATH:%pthread_dir%\lib milepost.dll.lib wasm3.lib pthreadVC3.lib set LIBS=/LIBPATH:bin milepost.dll.lib wasm3.lib
cl /Zi /Zc:preprocessor /std:c11 %INCLUDES% src\main.c /link %LIBS% /out:bin\orca.exe cl /Zi /Zc:preprocessor /std:c11 /experimental:c11atomics %INCLUDES% src\main.c /link %LIBS% /out:bin\orca.exe
) )

@ -1 +1 @@
Subproject commit 442d86386ebdc6e119ec765648420b6e096d145d Subproject commit 6ec113b708398bcf82a052a2bfb891b3265ca92e

View File

@ -7,7 +7,6 @@
*****************************************************************/ *****************************************************************/
#include<stdio.h> #include<stdio.h>
#include<errno.h> #include<errno.h>
#include<pthread.h>
#include<math.h> #include<math.h>
#define MG_INCLUDE_GL_API #define MG_INCLUDE_GL_API
@ -306,7 +305,7 @@ void orca_runtime_init(orca_runtime* runtime)
#include"gles_api_bind_gen.c" #include"gles_api_bind_gen.c"
#include"manual_gles_api.c" #include"manual_gles_api.c"
void* orca_runloop(void* user) i32 orca_runloop(void* user)
{ {
orca_app* app = &__orcaApp; orca_app* app = &__orcaApp;
@ -328,7 +327,7 @@ void* orca_runloop(void* user)
options); options);
mp_request_quit(); mp_request_quit();
return((void*)-1); return(-1);
} }
fseek(file, 0, SEEK_END); fseek(file, 0, SEEK_END);
@ -378,7 +377,7 @@ void* orca_runloop(void* user)
options); options);
mp_request_quit(); mp_request_quit();
return((void*)-1); return(-1);
} }
//NOTE: Find and type check event handlers. //NOTE: Find and type check event handlers.
@ -473,7 +472,7 @@ void* orca_runloop(void* user)
options); options);
mp_request_quit(); mp_request_quit();
return((void*)-1); return(-1);
} }
} }
@ -803,8 +802,7 @@ int main(int argc, char** argv)
mp_window_focus(app->window); mp_window_focus(app->window);
mp_window_center(app->window); mp_window_center(app->window);
pthread_t runloopThread; mp_thread* runloopThread = mp_thread_create(orca_runloop, 0);
pthread_create(&runloopThread, 0, orca_runloop, 0);
while(!mp_should_quit()) while(!mp_should_quit())
{ {
@ -812,8 +810,7 @@ int main(int argc, char** argv)
//TODO: what to do with mem scratch here? //TODO: what to do with mem scratch here?
} }
void* res; mp_thread_join(runloopThread, NULL);
pthread_join(runloopThread, &res);
mg_canvas_destroy(app->canvas); mg_canvas_destroy(app->canvas);
mg_surface_destroy(app->surface); mg_surface_destroy(app->surface);