Main Page   Class Hierarchy   Alphabetical List   Data Structures   File List   Data Fields  

clawsoft::Thread Class Reference

#include <Thread.h>

Inheritance diagram for clawsoft::Thread:

Inheritance graph
[legend]
Collaboration diagram for clawsoft::Thread:

Collaboration graph
[legend]

Detailed Description

This class encapsulates the thread library functionality through SDL and GNU Pth.


Public Types

enum  SchedPolicy { NORMAL, ROUND_ROBIN, FIFO }

Public Methods

 Thread ()
 Default constructor.

virtual ~Thread ()
 This is the class destructor, it simply calls detach for cleanup purposes.

int start ()
 Call this method when you want to start running your thread.

virtual void * run ()=0
 Very important
You must override this method so you can provide the thread process itself whatever you define this method does in your subclass is what the thread will start doing when you call start()


void killMe ()
 This method detaches the thread from the current running program, just like detach() does.

bool isRunning ()
 Use this method to verify if your thread is running;.

void setSchedulingPolicy (SchedPolicy pol=NORMAL)
 This method will set the scheduling policy for the current thread, there are two types scheduling policies: * Realtime * Non-realtime Realtime policies are the ROUND_ROBIN and FIFO Non-realime is called NORMAL.

void setPriority (int prio)
 Use this method to set the priority for the current scheduling policy.

const char * getClassName ()
 Returns the name of the current class.


Static Public Methods

int installedCPUs ()
 This will return how many CPUs are installed in the system.

double cpuSpeed ()
 This will return the CPU speed in megahertz.

int totalMemory ()
 Will return the total amount of system memory.

int freeMemory ()
 Will return the total amount of free system memory.

void usleep (Uint32 usec)
 Will freeze the software for usec microseconds.


Data Fields

bool autodetach
 This variable is just for knowing if the thread can be autodetached or no, currently it does nothing, but is here for backward compatibility.


Protected Methods

int _start ()
 This is a wrapper and is intended to be used only for derived classes.

void detach ()
 This method detaches the thread from the current running program.

void setClassName (const char *n)
 Call this method when you need to set the name of the class you're creating, typically in it's constructor, remember that you must set the classname for every class you create, that way you can have more information while debugging.


Static Private Methods

void * runMethod (void *thethread)
 This is the wrapping function which calls the run method so it can be executed as a thread, for GNU Pth this function must return an int.


Private Attributes

bool _running
 This flag will say if this thread is running or not.

pthread_t thread
 Thread identifier this one is used when GNU Pth has been activated.

pthread_attr_t t_attr
 This member will hold the attributes for the current thread.


Member Enumeration Documentation

enum clawsoft::Thread::SchedPolicy
 

Enumeration values:
NORMAL  Default scheduling policy, non-realtime.
ROUND_ROBIN  Round Robin based realtime scheduling policy.
FIFO  First In First Out based realtime scheduling policy.


Constructor & Destructor Documentation

clawsoft::Thread::Thread  
 

Default constructor.

virtual clawsoft::Thread::~Thread   [inline, virtual]
 

This is the class destructor, it simply calls detach for cleanup purposes.


Member Function Documentation

int clawsoft::Thread::_start   [protected]
 

This is a wrapper and is intended to be used only for derived classes.

double clawsoft::System::cpuSpeed   [static, inherited]
 

This will return the CPU speed in megahertz.

void clawsoft::Thread::detach   [protected]
 

This method detaches the thread from the current running program.

int clawsoft::System::freeMemory   [static, inherited]
 

Will return the total amount of free system memory.

const char * clawsoft::Object::getClassName   [inherited]
 

Returns the name of the current class.

int clawsoft::System::installedCPUs   [static, inherited]
 

This will return how many CPUs are installed in the system.

bool clawsoft::Thread::isRunning   [inline]
 

Use this method to verify if your thread is running;.

void clawsoft::Thread::killMe  
 

This method detaches the thread from the current running program, just like detach() does.

void * clawsoft::Thread::run   [pure virtual]
 

Very important
You must override this method so you can provide the thread process itself whatever you define this method does in your subclass is what the thread will start doing when you call start()

Implemented in clawsoft::AutomatedGC.

void * clawsoft::Thread::runMethod void *    thethread [static, private]
 

This is the wrapping function which calls the run method so it can be executed as a thread, for GNU Pth this function must return an int.

void clawsoft::Object::setClassName const char *    n [protected, inherited]
 

Call this method when you need to set the name of the class you're creating, typically in it's constructor, remember that you must set the classname for every class you create, that way you can have more information while debugging.

void clawsoft::Thread::setPriority int    prio
 

Use this method to set the priority for the current scheduling policy.

void clawsoft::Thread::setSchedulingPolicy SchedPolicy    pol = NORMAL
 

This method will set the scheduling policy for the current thread, there are two types scheduling policies: * Realtime * Non-realtime Realtime policies are the ROUND_ROBIN and FIFO Non-realime is called NORMAL.

int clawsoft::Thread::start  
 

Call this method when you want to start running your thread.

int clawsoft::System::totalMemory   [static, inherited]
 

Will return the total amount of system memory.

void clawsoft::System::usleep Uint32    usec [static, inherited]
 

Will freeze the software for usec microseconds.


Field Documentation

bool clawsoft::Thread::_running [private]
 

This flag will say if this thread is running or not.

bool clawsoft::Thread::autodetach
 

This variable is just for knowing if the thread can be autodetached or no, currently it does nothing, but is here for backward compatibility.

pthread_attr_t clawsoft::Thread::t_attr [private]
 

This member will hold the attributes for the current thread.

pthread_t clawsoft::Thread::thread [private]
 

Thread identifier this one is used when GNU Pth has been activated.


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

Authors:

Juan V. Guerrero
Jannette C. Mejia
Juan C. Guevara

Powered by:

SourceForgeLogo