![]()
|
thread.h00001 //
00002 // thread.h
00003 //
00004 // Copyright (C) 1997 Limit Point Systems, Inc.
00005 //
00006 // Author: Edward Seidl <seidl@janed.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB. If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027
00028 #ifndef _util_group_thread_h
00029 #define _util_group_thread_h
00030
00031 #ifdef __GNUC__
00032 #pragma interface
00033 #endif
00034
00035 #include <util/class/class.h>
00036
00037 namespace sc {
00038
00042 class ThreadLock : public RefCount {
00043 public:
00044 ThreadLock();
00045 virtual ~ThreadLock();
00046
00048 virtual void lock() =0;
00050 virtual void unlock() =0;
00051 };
00052
00053
00056 class Thread {
00057 public:
00058 Thread();
00059 virtual ~Thread();
00060
00061 static void *run_Thread_run(void*thread);
00062
00064 virtual void run() =0;
00065 };
00066
00069 class ThreadGrp: public DescribedClass {
00070 protected:
00071 Thread** threads_;
00072 int nthread_;
00073
00074 public:
00075 ThreadGrp();
00076 ThreadGrp(const Ref<KeyVal>&);
00077 ThreadGrp(const ThreadGrp&, int nthread = -1);
00078 virtual ~ThreadGrp();
00079
00082 virtual void add_thread(int threadnum, Thread* thread);
00086 virtual void add_thread(int threadnum, Thread* thread, int priority);
00088 int nthread() const { return nthread_; }
00089
00090 void delete_threads();
00091
00094 virtual int start_threads() =0;
00097 virtual int wait_threads() =0;
00099 virtual Ref<ThreadLock> new_lock() =0;
00100
00105 virtual ThreadGrp* clone(int nthread = -1);
00106
00107 static void set_default_threadgrp(const Ref<ThreadGrp>&);
00108 static ThreadGrp * get_default_threadgrp();
00109 static ThreadGrp * initial_threadgrp(int &argc, char ** argv);
00110 };
00111
00112
00116 class ProcThreadGrp: public ThreadGrp {
00117 public:
00118 ProcThreadGrp();
00119 ProcThreadGrp(const Ref<KeyVal>&);
00120 ~ProcThreadGrp();
00121
00122 int start_threads();
00123 int wait_threads();
00124
00125 Ref<ThreadLock> new_lock();
00126
00127 ThreadGrp* clone(int nthread = -1);
00128 };
00129
00130 }
00131
00132 extern "C" {
00133 // a C linkage interface to run_Thread_run
00134 void *Thread__run_Thread_run(void*thread);
00135 }
00136
00137 #endif
00138
00139 // Local Variables:
00140 // mode: c++
00141 // c-file-style: "ETS"
00142 // End:
Generated at Fri Jan 10 08:14:10 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |