2002-08-01 09:20:31 -07:00
|
|
|
/* cygthread.h
|
|
|
|
|
2004-01-18 21:46:54 -08:00
|
|
|
Copyright 1998, 1999, 2000, 2001, 2002, 2003, 2004 Red Hat, Inc.
|
2002-08-01 09:20:31 -07: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-25 20:15:10 -08:00
|
|
|
#ifndef _CYGTHREAD_H
|
|
|
|
#define _CYGTHREAD_H
|
|
|
|
|
2002-08-01 09:20:31 -07:00
|
|
|
class cygthread
|
|
|
|
{
|
2003-04-09 22:27:34 -07:00
|
|
|
LONG inuse;
|
2002-08-01 09:20:31 -07:00
|
|
|
DWORD id;
|
|
|
|
HANDLE h;
|
|
|
|
HANDLE ev;
|
2002-10-13 11:16:33 -07:00
|
|
|
HANDLE thread_sync;
|
2002-12-10 20:00:04 -08:00
|
|
|
void *stack_ptr;
|
2002-08-01 09:20:31 -07:00
|
|
|
const char *__name;
|
2004-12-22 10:12:30 -08:00
|
|
|
#ifdef DEBUGGING
|
|
|
|
const char *__oldname;
|
|
|
|
bool terminated;
|
|
|
|
#endif
|
2002-08-01 09:20:31 -07:00
|
|
|
LPTHREAD_START_ROUTINE func;
|
|
|
|
VOID *arg;
|
2002-08-28 20:33:50 -07:00
|
|
|
bool is_freerange;
|
2002-10-22 13:16:31 -07:00
|
|
|
static bool exiting;
|
2002-08-01 09:20:31 -07:00
|
|
|
public:
|
2004-12-05 13:29:37 -08:00
|
|
|
void terminate_thread ();
|
2003-12-13 23:09:22 -08:00
|
|
|
static DWORD WINAPI stub (VOID *);
|
2004-01-14 07:45:37 -08:00
|
|
|
static DWORD WINAPI simplestub (VOID *);
|
2003-08-27 19:04:16 -07:00
|
|
|
static DWORD main_thread_id;
|
2002-08-01 09:20:31 -07:00
|
|
|
static const char * name (DWORD = 0);
|
2004-12-23 06:57:08 -08:00
|
|
|
void auto_release () {func = NULL;}
|
2004-12-22 10:12:30 -08:00
|
|
|
void release (bool);
|
2002-08-01 09:20:31 -07:00
|
|
|
cygthread (LPTHREAD_START_ROUTINE, LPVOID, const char *);
|
|
|
|
cygthread () {};
|
|
|
|
static void init ();
|
2002-12-13 20:01:32 -08:00
|
|
|
bool detach (HANDLE = NULL);
|
2002-08-01 09:20:31 -07:00
|
|
|
operator HANDLE ();
|
|
|
|
void * operator new (size_t);
|
2002-10-22 13:16:31 -07:00
|
|
|
static cygthread *freerange ();
|
2002-09-28 19:19:35 -07:00
|
|
|
static void terminate ();
|
2002-10-08 22:55:40 -07:00
|
|
|
bool SetThreadPriority (int nPriority) {return ::SetThreadPriority (h, nPriority);}
|
|
|
|
void zap_h ()
|
|
|
|
{
|
|
|
|
(void) CloseHandle (h);
|
|
|
|
h = NULL;
|
|
|
|
}
|
2002-08-01 09:20:31 -07:00
|
|
|
};
|
2002-08-05 22:08:55 -07:00
|
|
|
|
|
|
|
#define cygself NULL
|
2004-11-25 20:15:10 -08:00
|
|
|
#endif /*_CYGTHREAD_H*/
|