newlib/winsup/cygwin/cygthread.h
Christopher Faylor d525130f04 * cygthread.cc (cygthread::exiting): New variable.
(cygthread::initialized): Delete.
(cygthread::stub): Use exiting variable to determine when to exit.
(cygthread::runner): Delete.
(cygthread_protect): New variable.
(cygthread::init): Don't start runner thread.  Initialize muto for list
protection.
(cygthread::freerange): Return pointer to cygthread.
(cygthread::operator new): Change logic to start threads on an as-needed basis.
(cygthread::detach): Don't zero id.
(cygthread::terminate): Don't kill any executing threads.  Just set exiting
flag.
* cygthread.h (cygthread): Reflect above changes.
* dcrt0.cc (dll_crt0_1): Move cygthread initialization later.
* fork.cc (fork_child): Do fdtab fixup after dll fixup or (apparently) winsock
may allocate memory in dll load address.
2002-10-22 20:16:31 +00:00

46 lines
1.0 KiB
C++

/* cygthread.h
Copyright 1998, 1999, 2000, 2001, 2002 Red Hat, Inc.
This software is a copyrighted work licensed under the terms of the
Cygwin license. Please consult the file "CYGWIN_LICENSE" for
details. */
class cygthread
{
DWORD avail;
DWORD id;
HANDLE h;
HANDLE ev;
HANDLE thread_sync;
const char *__name;
LPTHREAD_START_ROUTINE func;
VOID *arg;
bool is_freerange;
static DWORD main_thread_id;
static bool exiting;
static DWORD WINAPI stub (VOID *);
static DWORD WINAPI simplestub (VOID *);
public:
static const char * name (DWORD = 0);
cygthread (LPTHREAD_START_ROUTINE, LPVOID, const char *);
cygthread () {};
static void init ();
void detach ();
operator HANDLE ();
static bool is ();
void * operator new (size_t);
static cygthread *freerange ();
void exit_thread ();
static void terminate ();
bool SetThreadPriority (int nPriority) {return ::SetThreadPriority (h, nPriority);}
void zap_h ()
{
(void) CloseHandle (h);
h = NULL;
}
};
#define cygself NULL