golib  0.5
goThreadObject Class Reference

Base class for objects that implement threads. More...

#include <gothreadobject.h>

Public Member Functions

virtual ~goThreadObject ()
 
virtual void run (int nt=1)
 
virtual void threadMethod ()
 
goThreadgetThread ()
 
bool isCurrentThread () const
 Check if this thread is the current one. More...
 
- Public Member Functions inherited from goObjectBase
 goObjectBase ()
 Constructor.
 
virtual ~goObjectBase ()
 Destructor. More...
 
const char * getClassName () const
 Returns the class name. More...
 
int getClassID () const
 
virtual goSize_t memoryUsage () const
 Returns the size of this object or some measure of its memory consumption. More...
 
void setObjectName (const char *name)
 Set name string for an object. More...
 
void setObjectName (const goString &name)
 Set name string for an object. More...
 
const goStringgetObjectName () const
 Get the object name. More...
 
virtual bool writeObjectFile (FILE *) const
 Write object to a file. More...
 
virtual bool readObjectFile (FILE *)
 Read object from a file. More...
 
void connectObject (goObjectBase *object)
 Connects an object to this object. More...
 
void disconnectObject (const goObjectBase *object)
 Disconnects an object from this object.
 
virtual bool callObjectMethod (int methodID, goObjectMethodParameters *param=NULL)
 Call an object method by identifier. More...
 
virtual bool queueObjectMethod (int methodID, goObjectMethodParameters *param=NULL, bool blocking=false)
 Enqueue a method call to an internal list of methods. More...
 
bool callQueuedMethods ()
 Call all queued methods. More...
 

Additional Inherited Members

- Protected Member Functions inherited from goObjectBase
void setClassID (int id)
 Sets the class name.
 
void printClassMessage (const char *msg)
 Sets the class name. More...
 
void printClassMessage (goString &msg)
 Prints an informational message to the calling console. More...
 
void sendObjectMessage (int messageID, void *data=NULL)
 Sends a message to all connected objects.
 
void sendObjectMessage (goObjectBase *object, int messageID, void *data=NULL)
 Sends a message to a specific object.
 
virtual void receiveObjectMessage (const goObjectMessage &message)
 Receive a message. More...
 

Detailed Description

Base class for objects that implement threads.

Reimplement method threadMethod() in derived classes. threadMethod() will be run in an extra thread when run() is called.

Date
7.1.2002
Author
Christian Gosch

Constructor & Destructor Documentation

◆ ~goThreadObject()

goThreadObject::~goThreadObject ( )
virtual

@TODO Think of a way to clean up threads nicely when object is destroyed.

Member Function Documentation

◆ getThread()

goThread& goThreadObject::getThread ( )
inline
Returns
A reference to the goThread object used to run the thread(s).

◆ isCurrentThread()

bool goThreadObject::isCurrentThread ( ) const
inline

Check if this thread is the current one.

Returns
True if this thread is the currently running thread, false otherwise.

◆ run()

void goThreadObject::run ( int  nt = 1)
virtual

Creates a new thread of execution. The thread function is threadMethod().

Parameters
ntNumber of threads to spawn. 1 by default. If this differs from 1, then threadMethod() is executed in nt threads at the same time.

◆ threadMethod()

void goThreadObject::threadMethod ( )
virtual

This method must be reimplemented by a subclass. This method contains the code of the new thread.

Reimplemented in MainWindowThread< MW >, and goNet::goNetObject.


The documentation for this class was generated from the following files: