CloudBuilder C++ SDK  v3.0.0
Making social games is easy !
Public Member Functions | Protected Member Functions | List of all members
CotCHelpers::CThread Class Referenceabstract

#include <CotCHelpers.h>

Inheritance diagram for CotCHelpers::CThread:
CotCHelpers::CRefClass

Public Member Functions

bool Start ()
 
bool Join ()
 
bool HasFinished ()
 
- Public Member Functions inherited from CotCHelpers::CRefClass
void Retain ()
 
void Release ()
 
 CRefClass (const CRefClass &other)
 
CRefClassoperator= (const CRefClass &other)
 

Protected Member Functions

virtual void Run ()=0
 

Additional Inherited Members

- Static Public Member Functions inherited from CotCHelpers::CRefClass
template<class T >
static T * Retain (T *t)
 
template<class T >
static T * Release (T *t)
 
- Public Attributes inherited from CotCHelpers::CRefClass
unsigned __ref_count
 

Detailed Description

Simple thread. Just provide an implementation for the Run() method and start it by calling Start() on the resulting instance. This is a CRefClass, meaning that you need to call Release() on it when you are done using it. Do not delete it directly (if the thread is being run, your program will crash). To start a task and forget about it, you may do as follows:

struct MyTask: public CThread {
virtual void Run() {
printf("Starting\n");
usleep(3 * 1000 * 1000);
printf("Done\n");
}
};
MyTask *t = new MyTask;
t->Start();
t->Release();

Member Function Documentation

◆ HasFinished()

bool CotCHelpers::CThread::HasFinished ( )
inline
Returns
whether the thread has completed its work.

◆ Join()

bool CotCHelpers::CThread::Join ( )

Joins with the thread, waiting for it to end and returning only once done.

Returns
whether everything went well (but regardless of the return value, the thread shouldn't be running anymore upon return)

◆ Run()

virtual void CotCHelpers::CThread::Run ( )
protectedpure virtual

Override and implement your threaded work in this method. Never call this directly, use RunForInternalUse instead.

◆ Start()

bool CotCHelpers::CThread::Start ( )

Starts the execution of the thread (instantiating is not enough). Note that starting a thread automatically Retains it until execution finishes.

Returns
whether the thread could be started. Note that you cannot start a thread twice, even if it has finished.

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