mirror of
https://github.com/aseprite/aseprite.git
synced 2024-12-28 15:20:15 +00:00
Now windows threads implementation uses CreateThread instead of _beginthread.
This commit is contained in:
parent
4ccb661bbf
commit
9774059a9a
@ -43,12 +43,23 @@
|
|||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
#if defined ALLEGRO_UNIX || defined ALLEGRO_MACOSX
|
|
||||||
struct pthread_proxy_data {
|
struct pthread_proxy_data {
|
||||||
void (*proc)(void*);
|
void (*proc)(void*);
|
||||||
void* data;
|
void* data;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
#if defined ALLEGRO_WINDOWS
|
||||||
|
static DWORD WINAPI pthread_proxy(void* arg)
|
||||||
|
{
|
||||||
|
pthread_proxy_data* ptr = reinterpret_cast<pthread_proxy_data*>(arg);
|
||||||
|
void (*proc)(void*) = ptr->proc;
|
||||||
|
void* data = ptr->data;
|
||||||
|
jfree(ptr);
|
||||||
|
|
||||||
|
(*proc)(data);
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
#elif defined ALLEGRO_UNIX || defined ALLEGRO_MACOSX
|
||||||
static void* pthread_proxy(void* arg)
|
static void* pthread_proxy(void* arg)
|
||||||
{
|
{
|
||||||
pthread_proxy_data* ptr = reinterpret_cast<pthread_proxy_data*>(arg);
|
pthread_proxy_data* ptr = reinterpret_cast<pthread_proxy_data*>(arg);
|
||||||
@ -63,18 +74,27 @@ static void* pthread_proxy(void* arg)
|
|||||||
|
|
||||||
JThread jthread_new(void (*proc)(void*), void* data)
|
JThread jthread_new(void (*proc)(void*), void* data)
|
||||||
{
|
{
|
||||||
#if defined ALLEGRO_WINDOWS
|
|
||||||
return (JThread)_beginthread(proc, 0, data);
|
|
||||||
#elif defined ALLEGRO_UNIX || defined ALLEGRO_MACOSX
|
|
||||||
pthread_t thread = 0;
|
|
||||||
struct pthread_proxy_data *ptr = jnew(struct pthread_proxy_data, 1);
|
struct pthread_proxy_data *ptr = jnew(struct pthread_proxy_data, 1);
|
||||||
ptr->proc = proc;
|
ptr->proc = proc;
|
||||||
ptr->data = data;
|
ptr->data = data;
|
||||||
|
|
||||||
|
#if defined ALLEGRO_WINDOWS
|
||||||
|
|
||||||
|
DWORD id;
|
||||||
|
HANDLE thread = CreateThread(NULL, 0, pthread_proxy, ptr,
|
||||||
|
CREATE_SUSPENDED, &id);
|
||||||
|
if (thread)
|
||||||
|
ResumeThread(thread);
|
||||||
|
return thread;
|
||||||
|
|
||||||
|
#elif defined ALLEGRO_UNIX || defined ALLEGRO_MACOSX
|
||||||
|
|
||||||
|
pthread_t thread = 0;
|
||||||
if (pthread_create(&thread, NULL, pthread_proxy, ptr))
|
if (pthread_create(&thread, NULL, pthread_proxy, ptr))
|
||||||
return NULL;
|
return NULL;
|
||||||
else
|
else
|
||||||
return (JThread)thread;
|
return (JThread)thread;
|
||||||
|
|
||||||
#else
|
#else
|
||||||
#error ASE does not support threads for your platform
|
#error ASE does not support threads for your platform
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user