3 This software is a copyrighted work licensed under the terms of the
4 Cygwin license. Please consult the file "CYGWIN_LICENSE" for
10 typedef void (*LPVOID_THREAD_START_ROUTINE
) (void *) __attribute__((noreturn
)); // Input queue thread
22 const char *__oldname
;
25 LPTHREAD_START_ROUTINE func
;
30 HANDLE notify_detached
;
32 static void CALLBACK
async_create (ULONG_PTR
);
34 bool terminate_thread ();
35 static DWORD
stub (VOID
*);
36 static DWORD
simplestub (VOID
*);
37 static DWORD main_thread_id
;
38 static const char *name (DWORD
= 0);
39 void callfunc (bool) __attribute__ ((noinline
, ));
40 void auto_release () {func
= NULL
;}
42 cygthread (LPTHREAD_START_ROUTINE start
, unsigned n
, LPVOID param
, const char *name
, HANDLE notify
= NULL
)
43 : __name (name
), func (start
), arglen (n
), arg (param
),
44 notify_detached (notify
)
48 cygthread (LPVOID_THREAD_START_ROUTINE start
, LPVOID param
, const char *name
)
49 : __name (name
), func ((LPTHREAD_START_ROUTINE
) start
), arglen (0),
50 arg (param
), notify_detached (NULL
)
52 QueueUserAPC (async_create
, GetCurrentThread (), (ULONG_PTR
) this);
54 cygthread (LPTHREAD_START_ROUTINE start
, LPVOID param
, const char *name
, HANDLE notify
= NULL
)
55 : __name (name
), func (start
), arglen (0), arg (param
),
56 notify_detached (notify
)
60 cygthread (LPVOID_THREAD_START_ROUTINE start
, unsigned n
, LPVOID param
, const char *name
)
61 : __name (name
), func ((LPTHREAD_START_ROUTINE
) start
), arglen (n
),
62 arg (param
), notify_detached (NULL
)
64 QueueUserAPC (async_create
, GetCurrentThread (), (ULONG_PTR
) this);
68 bool detach (HANDLE
= NULL
);
70 void * operator new (size_t);
71 static cygthread
*freerange ();
72 static void terminate ();
73 HANDLE
thread_handle () const {return h
;}
74 bool SetThreadPriority (int nPriority
) {return ::SetThreadPriority (h
, nPriority
);}
83 #endif /*_CYGTHREAD_H*/