16#include "objfw-defs.h"
20#if !defined(OF_HAVE_THREADS) || \
21 (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
22# error No threads available!
27#if defined(OF_HAVE_PTHREADS)
29typedef pthread_t OFPlainThread;
30#elif defined(OF_WINDOWS)
32typedef HANDLE OFPlainThread;
33#elif defined(OF_AMIGAOS)
34# include <exec/tasks.h>
35# include <exec/semaphores.h>
40 struct SignalSemaphore semaphore;
41 struct Task *joinTask;
42 unsigned char joinSigBit;
50} OFPlainThreadAttributes;
52#if defined(OF_HAVE_PTHREADS)
53static OF_INLINE OFPlainThread
54OFCurrentPlainThread(
void)
56 return pthread_self();
60OFPlainThreadIsCurrent(OFPlainThread thread)
62 return pthread_equal(thread, pthread_self());
64#elif defined(OF_WINDOWS)
65static OF_INLINE OFPlainThread
66OFCurrentPlainThread(
void)
68 return GetCurrentThread();
72OFPlainThreadIsCurrent(OFPlainThread thread)
74 return (thread == GetCurrentThread());
76#elif defined(OF_AMIGAOS)
77extern OFPlainThread OFCurrentPlainThread(
void);
78extern bool OFPlainThreadIsCurrent(OFPlainThread);
84extern int OFPlainThreadAttributesInit(OFPlainThreadAttributes *attr);
85extern int OFPlainThreadNew(OFPlainThread *thread,
const char *name,
86 void (*function)(
id),
id object,
const OFPlainThreadAttributes *attr);
87extern void OFSetThreadName(
const char *name);
88extern int OFPlainThreadJoin(OFPlainThread thread);
89extern int OFPlainThreadDetach(OFPlainThread thread);