/** SGX

The   sss    gggg x   x   
     s      g      x x    Engine
      sss   g  gg   x
         s  g   g  x x          Copyright 1995-2009.
     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: sgx/src/sgx/core/threading/thread.cpp

*/

#include "sgx/core/core.hpp"

tBOOL	
sgxCoreThreadCallbackHandler::onCoreThreadStarted(const CSGXThread *pThread) {
	SGX_UNUSED(pThread);
	return TRUE;
}

tBOOL	
sgxCoreThreadCallbackHandler::onCoreThreadSuspended(const CSGXThread *pThread) {
	SGX_UNUSED(pThread);
	return TRUE;
}

tBOOL	
sgxCoreThreadCallbackHandler::onCoreThreadResumed(const CSGXThread *pThread) {
	SGX_UNUSED(pThread);
	return TRUE;
}

tBOOL	
sgxCoreThreadCallbackHandler::onCoreThreadFinished(const CSGXThread *pThread, const tMEM_SIZE result) {
	SGX_UNUSED(pThread);
	SGX_UNUSED(result);
	return TRUE;
}


CSGXThread::CSGXThread(const sgxCPU *pOnCPU)
{
	m_State = SGX_THREAD_STATE_INITIALIZING;
	m_pCPU = pOnCPU;
	m_CallbackToStartThread = NULL;
}

tMEM_SIZE CSGXThread::start() 
{
	onCoreThreadStarted(this);
	return 0;
}

void CSGXThread::suspend()
{
	onCoreThreadSuspended(this);
	m_State = SGX_THREAD_STATE_PAUSED;
}

void CSGXThread::resume()
{
	onCoreThreadResumed(this);
	m_State = SGX_THREAD_STATE_RUNNING;
}

void CSGXThread::end(const tMEM_SIZE result) 
{
	onCoreThreadFinished(this, result);
	CSGXThreadManager::get()->destroy(this);
}

