23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
typedef DWORD of_tlskey_t;
#endif
#ifndef _WIN32
#define of_thread_is_current(t) pthread_equal(t, pthread_self())
#define of_thread_current() pthread_self()
#else
#define of_thread_is_current(t) (t == GetCurrentThreadId())
#define of_thread_current() GetCurrentThreadId()
#endif
static OF_INLINE BOOL
of_thread_new(of_thread_t *thread, id (*main)(id), id data)
{
#ifndef _WIN32
return (pthread_create(thread, NULL, (void*(*)(void*))main,
(void*)data) ? NO : YES);
#else
*thread = CreateThread(NULL, 0, (void*(*)(void*))main,
(void*)data, 0, NULL);
return (thread == NULL ? NO : YES);
#endif
}
static OF_INLINE BOOL
|
|
|
|
|
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
|
typedef DWORD of_tlskey_t;
#endif
#ifndef _WIN32
#define of_thread_is_current(t) pthread_equal(t, pthread_self())
#define of_thread_current() pthread_self()
#else
#define of_thread_is_current(t) (t == GetCurrentThread())
#define of_thread_current() GetCurrentThread()
#endif
static OF_INLINE BOOL
of_thread_new(of_thread_t *thread, id (*main)(id), id data)
{
#ifndef _WIN32
return (pthread_create(thread, NULL, (void*(*)(void*))main,
(void*)data) ? NO : YES);
#else
*thread = CreateThread(NULL, 0, (LPTHREAD_START_ROUTINE)main,
(void*)data, 0, NULL);
return (thread == NULL ? NO : YES);
#endif
}
static OF_INLINE BOOL
|