2002-08-02 00:20:31 +08:00
|
|
|
/* cygthread.h
|
|
|
|
|
2004-01-19 13:46:54 +08:00
|
|
|
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
|
2002-08-02 00:20:31 +08:00
|
|
|
|
|
|
|
This software is a copyrighted work licensed under the terms of the
|
|
|
|
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
|
|
|
|
details. */
|
|
|
|
|
2004-11-26 12:15:10 +08:00
|
|
|
#ifndef _CYGTHREAD_H
|
|
|
|
#define _CYGTHREAD_H
|
|
|
|
|
2002-08-02 00:20:31 +08:00
|
|
|
class cygthread
|
|
|
|
{
|
2003-04-10 13:27:34 +08:00
|
|
|
LONG inuse;
|
2002-08-02 00:20:31 +08:00
|
|
|
DWORD id;
|
|
|
|
HANDLE h;
|
|
|
|
HANDLE ev;
|
2002-10-14 02:16:33 +08:00
|
|
|
HANDLE thread_sync;
|
2002-12-11 12:00:04 +08:00
|
|
|
void *stack_ptr;
|
2002-08-02 00:20:31 +08:00
|
|
|
const char *__name;
|
2004-12-23 02:12:30 +08:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
const char *__oldname;
|
|
|
|
bool terminated;
|
|
|
|
#endif
|
2002-08-02 00:20:31 +08:00
|
|
|
LPTHREAD_START_ROUTINE func;
|
|
|
|
VOID *arg;
|
2002-08-29 11:33:50 +08:00
|
|
|
bool is_freerange;
|
2002-10-23 04:16:31 +08:00
|
|
|
static bool exiting;
|
2002-08-02 00:20:31 +08:00
|
|
|
public:
|
2004-12-06 05:29:37 +08:00
|
|
|
void terminate_thread ();
|
2003-12-14 15:09:22 +08:00
|
|
|
static DWORD WINAPI stub (VOID *);
|
2004-01-14 23:45:37 +08:00
|
|
|
static DWORD WINAPI simplestub (VOID *);
|
2003-08-28 10:04:16 +08:00
|
|
|
static DWORD main_thread_id;
|
2002-08-02 00:20:31 +08:00
|
|
|
static const char * name (DWORD = 0);
|
2004-12-23 02:12:30 +08:00
|
|
|
void release (bool);
|
2002-08-02 00:20:31 +08:00
|
|
|
cygthread (LPTHREAD_START_ROUTINE, LPVOID, const char *);
|
|
|
|
cygthread () {};
|
|
|
|
static void init ();
|
2002-12-14 12:01:32 +08:00
|
|
|
bool detach (HANDLE = NULL);
|
2002-08-02 00:20:31 +08:00
|
|
|
operator HANDLE ();
|
|
|
|
void * operator new (size_t);
|
2002-10-23 04:16:31 +08:00
|
|
|
static cygthread *freerange ();
|
2002-08-02 10:10:24 +08:00
|
|
|
void exit_thread ();
|
2002-09-29 10:19:35 +08:00
|
|
|
static void terminate ();
|
2002-10-09 13:55:40 +08:00
|
|
|
bool SetThreadPriority (int nPriority) {return ::SetThreadPriority (h, nPriority);}
|
|
|
|
void zap_h ()
|
|
|
|
{
|
|
|
|
(void) CloseHandle (h);
|
|
|
|
h = NULL;
|
|
|
|
}
|
2002-08-02 00:20:31 +08:00
|
|
|
};
|
2002-08-06 13:08:55 +08:00
|
|
|
|
|
|
|
#define cygself NULL
|
2004-11-26 12:15:10 +08:00
|
|
|
#endif /*_CYGTHREAD_H*/
|