3 Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2010,
6 This software is a copyrighted work licensed under the terms of the
7 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
13 typedef void WINAPI (*LPVOID_THREAD_START_ROUTINE) (void *) __attribute__((noreturn)); // Input queue thread
25 const char *__oldname;
28 LPTHREAD_START_ROUTINE func;
33 HANDLE notify_detached;
34 void create () __attribute__ ((regparm (1)));
35 static void CALLBACK async_create (ULONG_PTR);
37 bool terminate_thread ();
38 static DWORD WINAPI stub (VOID *);
39 static DWORD WINAPI simplestub (VOID *);
40 static DWORD main_thread_id;
41 static const char *name (DWORD = 0);
42 void callfunc (bool) __attribute__ ((noinline, regparm (2)));
43 void auto_release () {func = NULL;}
45 cygthread (LPTHREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name, HANDLE notify = NULL)
46 : __name (name), func (start), arglen (n), arg (param),
47 notify_detached (notify)
51 cygthread (LPVOID_THREAD_START_ROUTINE start, LPVOID param, const char *name)
52 : __name (name), func ((LPTHREAD_START_ROUTINE) start), arglen (0),
53 arg (param), notify_detached (NULL)
55 QueueUserAPC (async_create, GetCurrentThread (), (ULONG_PTR) this);
57 cygthread (LPTHREAD_START_ROUTINE start, LPVOID param, const char *name, HANDLE notify = NULL)
58 : __name (name), func (start), arglen (0), arg (param),
59 notify_detached (notify)
63 cygthread (LPVOID_THREAD_START_ROUTINE start, unsigned n, LPVOID param, const char *name)
64 : __name (name), func ((LPTHREAD_START_ROUTINE) start), arglen (n),
65 arg (param), notify_detached (NULL)
67 QueueUserAPC (async_create, GetCurrentThread (), (ULONG_PTR) this);
71 bool detach (HANDLE = NULL);
73 void * operator new (size_t);
74 static cygthread *freerange ();
75 static void terminate ();
76 HANDLE thread_handle () const {return h;}
77 bool SetThreadPriority (int nPriority) {return ::SetThreadPriority (h, nPriority);}
86 #endif /*_CYGTHREAD_H*/