/** 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: src/sgx/core/threading/thread.cpp

*/

#include "sgx/core/core.hpp"

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

tMEM_SIZE CThread::start() 
{
	if (m_CallbackToStartThread) {
		return (*m_CallbackToStartThread)(this);
	}
	return 0;
}

void CThread::suspend()
{
	m_State = SGX_THREAD_STATE_PAUSED;
}

void CThread::resume()
{
	m_State = SGX_THREAD_STATE_RUNNING;
}

void CThread::end() 
{
	CThreadManager::get()->destroy(this);
}

