/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2008.
     ssss    gggg x   x         Steven Goodwin. All Rights Reserved.
    
This version has been released under the GNU Public License v2.0.

Please see the license files for details.

File: include/sgx/core/threading/processthread.hpp

*/

#ifndef SGX_CORE_THREADING_PROCESSTHREAD_HPP
#define SGX_CORE_THREADING_PROCESSTHREAD_HPP	1

/**
This is a special class of thread. It contains a list of objects
within it that it processes continually.

  You can new objects at any time with,

ppt->addObject(pSgxObject)

  This will return immediately, and process the object on the next 
  iteration around the loop.

  The processing for each object calls the update method with a given
  time elapsed, specified by setTimeElapsed.
*/
class CSGXProcessThread : public CThread {
protected:
	sgxVector<sgxObject *>	m_List;
	sgxVector<sgxObject *>	m_AddList;

	CMutex *						m_ListAddMutex;
	tREAL32						m_Telaps;
	tREAL32						m_NewTelaps;

	tUINT32						m_TotalWeight;


public:
	CSGXProcessThread(const sgxCPU *pOnCPU=NULL);
	virtual ~CSGXProcessThread();
	virtual tMEM_SIZE start();

	void		addObject(sgxObject *pObj, tUINT32 iWeight = 1);
	void		setTimeElapsed(tREAL32 t);
	tUINT32	getNumprocesses() const;
	tUINT32	getNumprocessesWeighted() const;

};

#endif /* SGX_CORE_THREADING_PROCESSTHREAD_HPP */
