20#include "objfw-defs.h"
24#if !defined(OF_HAVE_THREADS) || \
25 (!defined(OF_HAVE_PTHREADS) && !defined(OF_WINDOWS) && !defined(OF_AMIGAOS))
26# error No threads available!
31#if defined(OF_HAVE_PTHREADS)
33typedef pthread_t OFPlainThread;
34#elif defined(OF_WINDOWS)
36typedef HANDLE OFPlainThread;
37#elif defined(OF_AMIGAOS)
38# include <exec/tasks.h>
39# include <exec/semaphores.h>
44 struct SignalSemaphore semaphore;
45 struct Task *joinTask;
46 unsigned char joinSigBit;
54} OFPlainThreadAttributes;
56#if defined(OF_HAVE_PTHREADS)
57static OF_INLINE OFPlainThread
58OFCurrentPlainThread(
void)
60 return pthread_self();
64OFPlainThreadIsCurrent(OFPlainThread thread)
66 return pthread_equal(thread, pthread_self());
68#elif defined(OF_WINDOWS)
69static OF_INLINE OFPlainThread
70OFCurrentPlainThread(
void)
72 return GetCurrentThread();
76OFPlainThreadIsCurrent(OFPlainThread thread)
78 return (thread == GetCurrentThread());
80#elif defined(OF_AMIGAOS)
81extern OFPlainThread OFCurrentPlainThread(
void);
82extern bool OFPlainThreadIsCurrent(OFPlainThread);
88extern int OFPlainThreadAttributesInit(OFPlainThreadAttributes *attr);
89extern int OFPlainThreadNew(OFPlainThread *thread,
const char *name,
90 void (*function)(
id),
id object,
const OFPlainThreadAttributes *attr);
91extern void OFSetThreadName(
const char *name);
92extern int OFPlainThreadJoin(OFPlainThread thread);
93extern int OFPlainThreadDetach(OFPlainThread thread);