You.i Engine
CYILoadThreadManager Class Reference

Detailed Description

A class that loads data in a pool of threads.

Any data that needs to be processed in a thread is required to implement the IYIRunOnThread interface. Internally, it instantiates a thread and configures it with the data.

Note
Function calls are executed in a separate manager thread.
Takes ownership of all data processed. It is also responsible for all the threads created.

#include <thread/YiLoadThreadManager.h>

Inheritance diagram for CYILoadThreadManager:

Public Member Functions

 CYILoadThreadManager (int32_t nThreads)
 
 ~CYILoadThreadManager ()
 
void StopManager ()
 
void Load (std::unique_ptr< IYIRunOnThread > pResource)
 
void Unload (const IYIRunOnThread *pResource)
 
- Public Member Functions inherited from CYIThread
 CYIThread (const CYIString &name=CYIString(), YI_PRIORITY ePriority=YI_PRIORITY_DEFAULT, uint32_t uStackSize=DEFAULT_STACK_SIZE)
 
virtual ~CYIThread ()
 
bool StartThread (YI_START_TYPE eStartType=BLOCK_UNTIL_STARTED)
 
void Terminate ()
 
void EnableTermination ()
 
void DisableTermination ()
 
bool IsTerminationEnabled ()
 
bool Join ()
 
bool Join (uint32_t uTimeoutMs)
 
bool IsRunning () const
 
CYIThreadHandle GetThreadId () const
 
void SetName (const CYIString &name)
 
const CYIStringGetName () const
 
void SetPriority (YI_PRIORITY priority)
 
YI_PRIORITY GetPriority () const
 
bool AddThreadListener (Listener *pListener)
 
bool RemoveThreadListener (Listener *pListener)
 
bool SetStackSize (uint32_t uStackSize)
 
uint32_t GetStackSize () const
 

Additional Inherited Members

- Public Types inherited from CYIThread
enum  YI_START_TYPE {
  BLOCK_UNTIL_STARTED = true,
  NON_BLOCKING = false
}
 
- Static Public Member Functions inherited from CYIThread
static CYIThreadHandle GetCurrentThreadId ()
 
static const CYIThreadHandleGetUIThreadId ()
 
static int32_t GetOSIdealThreadCount ()
 
static void Sleep (uint32_t uMillis)
 
static void YieldCurrentThread ()
 
static void ReportDefaults ()
 
- Static Public Attributes inherited from CYIThread
static const uint32_t DEFAULT_STACK_SIZE = 128 * 1024
 
- Protected Member Functions inherited from CYIThread
bool IsTerminationRequested () const
 

Constructor & Destructor Documentation

CYILoadThreadManager::CYILoadThreadManager ( int32_t  nThreads)

Initializes a pool of nThreads threads.

CYILoadThreadManager::~CYILoadThreadManager ( )

Member Function Documentation

void CYILoadThreadManager::Load ( std::unique_ptr< IYIRunOnThread pResource)

Loads pResource in a thread available in the pool.

void CYILoadThreadManager::StopManager ( )

Stops the manager to allow the manager thread to clean up resources. For proper use, every resource loaded in Load() needs to be unloaded with Unload().

void CYILoadThreadManager::Unload ( const IYIRunOnThread pResource)

Removes pResource from the manager.

Note
If the loading process has already started, it will wait for completion before releasing the resource.

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