Merge pull request #2216 from jwillemsen/jwi-cxxversionchecks
[ACE_TAO.git] / ACE / apps / JAWS / clients / WebSTONE / src / nsapi-includes / base / systhr.h
blobc7593a0296b6337f8e082308afc199e89c3e6dc8
1 /*
2 * Copyright (c) 1994, 1995. Netscape Communications Corporation. All
3 * rights reserved.
5 * Use of this software is governed by the terms of the license agreement for
6 * the Netscape Communications or Netscape Comemrce Server between the
7 * parties.
8 */
11 /* ------------------------------------------------------------------------ */
15 * systhr.h: Abstracted threading mechanisms
17 * Rob McCool
20 #ifndef _SYSTHR_H
21 #define _SYSTHR_H
23 #include "netsite.h"
24 #include "systems.h"
26 #ifdef THREAD_ANY
28 #ifdef USE_NSPR
29 #include <nspr/prthread.h>
30 #include <nspr/prglobal.h>
32 typedef PRThread* SYS_THREAD;
33 #endif
35 #ifdef THREAD_WIN32
36 #include <nspr/prthread.h>
37 #include <nspr/prglobal.h>
38 #include <process.h>
39 typedef struct {
40 HANDLE hand;
41 DWORD id;
42 } sys_thread_s;
43 typedef sys_thread_s *SYS_THREAD;
44 #endif
47 * systhread_start creates a thread with the given priority, will allocate
48 * a stack of stksz bytes, and calls fn with arg as its argument. stksz
49 * of zero will allocate a default stack size.
51 * XXX Priorities are system dependent
54 SYS_THREAD systhread_start(int prio, int stksz, void (*fn)(void *), void *arg);
57 * systhread_current returns a pointer to the current thread.
59 #ifdef USE_NSPR
60 #define systhread_current() PR_CurrentThread()
61 #elif defined(THREAD_WIN32)
62 #define systhread_current() GetCurrentThreadId()
63 #endif
66 * systhread_attach makes an existing thread an NSPR thread. Currently this
67 * is used only in NT.
70 SYS_THREAD systhread_attach();
73 * systhread_terminate terminates the thread that is passed in.
75 void systhread_terminate(SYS_THREAD thr);
79 * systhread_sleep puts the calling thread to sleep for the given number
80 * of milliseconds.
82 void systhread_sleep(int milliseconds);
85 * systhread_init initializes the threading system. name is a name for the
86 * program for debugging.
88 void systhread_init(char *name);
91 * systhread_timerset starts or re-sets the interrupt timer for a thread
92 * system. This should be considered a suggestion as most systems don't allow
93 * the timer interval to be changed.
95 #ifdef THREAD_NSPR_USER
96 #define systhread_timerset(usec) PR_StartEvents(usec)
98 #elif defined(USE_NSPR)
99 #define systhread_timerset(usec) (void)(usec)
101 #elif defined(THREAD_WIN32)
102 #define systhread_timerset(usec) (void)(usec)
103 #endif
107 * newkey allocates a new integer id for thread-private data. Use this
108 * key to identify a variable which you want to appear differently
109 * between threads, and then use setdata to associate a value with this
110 * key for each thread.
112 int systhread_newkey();
115 * Get data that has been previously associated with key in this thread.
116 * Returns NULL if setkey has not been called with this key by this
117 * thread previously, or the data that was previously used with setkey
118 * by this thread with this key.
120 void *systhread_getdata(int key);
123 * Associate data with the given key number in this thread.
125 void systhread_setdata(int key, void *data);
127 #endif
128 #endif