41 #ifndef Core_Thread_Thread_h
42 #define Core_Thread_Thread_h
58 struct Thread_private;
69 static const unsigned long long DEFAULT_STACKSIZE = 256 * 1024;
71 static const unsigned long long DEFAULT_STACKSIZE = 128 * 1024;
91 ActiveState state=Activated,
92 unsigned long long stack_size = DEFAULT_STACKSIZE);
100 Runnable* getRunnable();
105 void setDaemon(
bool to=
true);
109 bool isDaemon()
const;
115 void activate(
bool stopped);
125 bool isDetached()
const;
134 void setStackSize(
unsigned long long stackSize);
138 unsigned long long getStackSize()
const;
142 static void exitAll(
int code);
167 const char* getThreadName()
const;
171 static int numProcessors();
177 void migrate(
int proc);
186 int nthreads,
bool block,
198 if (numThreads <= 1) { (ptr->*pmf)(0); }
202 parallel(p, numThreads,
true);
208 template<
class T,
class Arg1>
209 static void parallel(T* ptr,
void (T::*pmf)(
int, Arg1),
210 int numThreads, Arg1 a1)
212 if (numThreads <= 1) { (ptr->*pmf)(0, a1); }
216 parallel(p, numThreads,
true);
222 template<
class T,
class Arg1,
class Arg2>
223 static void parallel(T* ptr,
void (T::* pmf)(
int, Arg1, Arg2),
224 int numThreads, Arg1 a1, Arg2 a2)
226 if (numThreads <= 1) { (ptr->*pmf)(0, a1, a2); }
230 parallel(p, numThreads,
true);
236 template<
class T,
class Arg1,
class Arg2,
class Arg3>
237 static void parallel(T* ptr,
void (T::* pmf)(
int, Arg1, Arg2, Arg3),
238 int numThreads, Arg1 a1, Arg2 a2, Arg3 a3)
240 if (numThreads <= 1) { (ptr->*pmf)(0, a1, a2, a3); }
244 parallel(p, numThreads,
true);
249 template<
class T,
class Arg1,
class Arg2,
class Arg3,
class Arg4>
250 static void parallel(T* ptr,
void (T::* pmf)(
int, Arg1, Arg2, Arg3, Arg4),
251 int numThreads, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4)
253 if (numThreads <= 1) { (ptr->*pmf)(0, a1, a2, a3, a4); }
257 parallel(p, numThreads,
true);
266 static void niceAbort(
void* Context = 0);
273 static int couldBlock(
const char* why);
279 static void couldBlockDone(
int restore);
288 static bool isInitialized();
292 static void setDefaultAbortMode(
const char* abortMode);
294 static void initialize();
296 friend class Runnable;
301 friend class SystemCallManager;
312 friend void install_signal_handlers();
319 const char* threadname_;
321 unsigned long long stacksize_;
326 void os_start(
bool stopped);
329 static bool initialized;
330 static void checkExit();
332 static const char* defaultAbortMode;
352 BLOCK_CONDITIONVARIABLE
355 static const char* getStateString(ThreadState);
357 static int push_bstack(
Thread_private*, Thread::ThreadState s,
const char* why);
360 static void print_threads();
void Thread_run(Thread *t)
Definition: Thread_pthreads.cc:377
static void parallel(T *ptr, void(T::*pmf)(int, Arg1), int numThreads, Arg1 a1)
Another overloaded version of parallel that passes 1 argument.
Definition: Thread.h:209
void exit_handler()
Definition: Thread_pthreads.cc:722
static void parallel(T *ptr, void(T::*pmf)(int, Arg1, Arg2), int numThreads, Arg1 a1, Arg2 a2)
Another overloaded version of parallel that passes 2 arguments.
Definition: Thread.h:223
void handle_quit(int sig)
Definition: Thread_pthreads.cc:609
Definition: RecursiveMutex.h:68
#define SCISHARE
Definition: share.h:39
Definition: ParallelBase.h:62
Definition: ConditionVariable.h:80
Definition: Parallel3.h:61
void Thread_shutdown(Thread *thread, bool)
Definition: Thread_pthreads.cc:228
Definition: Parallel1.h:61
Automatically instantiate several threads, with 2 arguments.
const char * name[]
Definition: BoostGraphExampleTests.cc:87
Definition: Parallel4.h:61
Definition: Parallel2.h:61
Definition: Parallel.h:61
Definition: Thread_pthreads.cc:112
void handle_siguser2(int)
Definition: Thread_pthreads.cc:648
static void parallel(T *ptr, void(T::*pmf)(int, Arg1, Arg2, Arg3, Arg4), int numThreads, Arg1 a1, Arg2 a2, Arg3 a3, Arg4 a4)
Another overloaded version of parallel that passes 4 arguments.
Definition: Thread.h:250
Automatically instantiate several threads, with 1 argument.
ActiveState
Possible thread start states.
Definition: Thread.h:75
void * run_threads(void *priv_v)
Definition: Thread_pthreads.cc:383
void handle_abort_signals(int sig, siginfo_t *info, void *)
Definition: Thread_pthreads.cc:537
Automatically instantiate several threads, with 4 arguments.
static void parallel(T *ptr, void(T::*pmf)(int), int numThreads)
Definition: Thread.h:195
Definition: ThreadGroup.h:68
static void parallel(T *ptr, void(T::*pmf)(int, Arg1, Arg2, Arg3), int numThreads, Arg1 a1, Arg2 a2, Arg3 a3)
Another overloaded version of parallel that passes 3 arguments.
Definition: Thread.h:237