28 #ifndef _util_group_thread_h 29 #define _util_group_thread_h 35 #include <util/class/class.h> 50 virtual void lock() =0;
70 void unlock() {
if (locked_) { lock_->unlock(); locked_ =
false; } }
72 void lock() {
if (!locked_) { lock_->lock(); locked_ =
true; } }
84 static void *run_Thread_run(
void*thread);
87 virtual void run() =0;
113 void delete_threads();
131 static ThreadGrp * get_default_threadgrp();
132 static ThreadGrp * initial_threadgrp(
int &argc,
char ** argv);
157 void *Thread__run_Thread_run(
void*thread);
ThreadGrp * clone(int nthread=-1)
Create a ThreadGrp like the current one.
virtual void lock()=0
Obtain the lock.
void unlock()
Release the lock before the DTOR is called, if it is still held.
Definition: thread.h:70
virtual ThreadGrp * clone(int nthread=-1)
Create a ThreadGrp like the current one.
Ref< ThreadLock > new_lock()
Return a local object.
virtual void unlock()=0
Release the lock.
The Thread abstract class defines an interface which must be implemented by classes wishing to be run...
Definition: thread.h:79
int wait_threads()
Wait for all the threads to complete.
Classes which need runtime information about themselves and their relationship to other classes can v...
Definition: class.h:244
The base class for all reference counted objects.
Definition: ref.h:194
A template class that maintains references counts.
Definition: ref.h:332
ThreadLockHolder(const Ref< ThreadLock > &l)
Acquires the lock.
Definition: thread.h:65
~ThreadLockHolder()
Releases the lock if it is still held.
Definition: thread.h:74
virtual Ref< ThreadLock > new_lock()=0
Return a local object.
The ThreadGrp abstract class provides a means to manage separate threads of control.
Definition: thread.h:92
int start_threads()
Starts the threads running.
virtual int start_threads()=0
Starts the threads running.
The ThreadLock abstract class provides mutex locks to be used in conjunction with ThreadGrp's...
Definition: thread.h:44
void lock()
Acquire the lock once more.
Definition: thread.h:72
The ProcThreadGrp class privides a concrete thread group appropriate for an environment where there i...
Definition: thread.h:139
virtual void add_thread(int threadnum, Thread *thread)
Assigns a Thread object to each thread.
virtual void run()=0
This is called with the Thread is run from a ThreadGrp.
Acquire a lock on creation and release it on destruction.
Definition: thread.h:60
int nthread() const
The number of threads that will be run by start_thread.
Definition: thread.h:111
virtual int wait_threads()=0
Wait for all the threads to complete.