#ifndef VTHREAD_HEADER #define VTHREAD_HEADER 1 ////////////////////////////////////////////////////////////// //! file="amma/Drivers/Thread/Base/VThread.hh" //! lib=VThread //! userlevel=Obsolete //! author="Charles Galambos" //! date="12/10/1995" //! docentry="Utilities.Threads" //! rcsid="$Id: VThread.hh,v 1.10 2000/03/09 11:58:10 ees1cg Exp $" #include "amma/Boolean.hh" class VThreadBody; //: Thread base class. // This class represents a single thread of execution within the program.
// Use PThread (Posix threads) library instead. class VThread { public: VThread(int MinStackSize = 16000,BooleanT Bind = FALSE); // Construct a new thread. virtual ~VThread(); // Destroy a thread, this will suspend the execution of the // thread. Care should be taken when deleting a thread to // ensure its not holding any external resources. // ------------- Base Interface ---------------------- BooleanT Execute(void); // Start thread running, use this command to start thread running // after it has been created. This function can only be called // once. virtual int Start(void); // Called when thread started. This function should be overloaded // is a derived class. It is called with the new thread after // Execute() is called. There is no need to call this function // directly. virtual int End(void); // Called when thread terminates normally. Overloading this method // is optional. There is no need to call this function // directly. // ------------- Execution control ---------------------- // These may be called by any thread. void Yield(void); // Yield control of processor, call if you wish a brief delay // in execution. void Terminate(void); // Terminate thread. // Call to stop the thread running. BooleanT Pause(void); // Stop thread running temporarly. BooleanT Continue(void); // Continue thread running again after call to Pause(). BooleanT SetPriority(int Pri); // Set the priority of the process // 0 to 32767, Higher faster. // ------------- Thread ID ---------------------- // Functions to identify threads. int GetID(void); // Get a unique ID for this thread. // NB. An id may no be assigned to the thread until // after Execute() has been called. static IntT GetCurrentThreadID(); //: Get ID of current thread. static VThread *GetCurrentThread(void); // Get a pointer to the currently executing thread. friend VThreadBody; private: VThreadBody *Body; }; #endif