//////////////////////////////////////////////////////////////////////////////
//
// Asura_Platform_MultithreadTypes.h
//
// Copyright (c) 2006 Rebellion. All rights reserved.
//
// Description:
//
//     PSP base classes to provide data for multithreading primitives
//
//////////////////////////////////////////////////////////////////////////////

// B E G I N   F I L E   W R A P P E R ///////////////////////////////////////

#ifdef ASURA_USE_PRAGMA_ONCE
    #pragma once
#endif

#ifndef ___ASURA_PLATFORM_MULTITHREADTYPES_H___
#define ___ASURA_PLATFORM_MULTITHREADTYPES_H___ 1

// Asura independent
#include "Debugging/Asura_Assert.h"

// PSP libraries
#include <kernel.h>

typedef int Asura_ThreadID;

class Asura_Platform_MutexData
{
public:

	Asura_Platform_MutexData()
    {
	    m_iSemaphoreId = sceKernelCreateSema("Asura mutex", SCE_KERNEL_SA_THFIFO, 1, 1, NULL);
		Asura_Assert(m_iSemaphoreId >= 0, "sceKernelCreateSema failed");
    }

    ~Asura_Platform_MutexData()
    {
#ifdef ASURA_ASSERT
		int iRet = 
#endif
		sceKernelDeleteSema(m_iSemaphoreId);
		Asura_Assert(iRet == SCE_KERNEL_ERROR_OK, "sceKernelCreateSema failed");
    }

protected:

	int m_iSemaphoreId;
};


class Asura_Platform_SyncEvent
{
public:

	Asura_Platform_SyncEvent( const char* szName, bool bStartsSignalled )
	{
	    m_iEventId = sceKernelCreateEventFlag(szName, SCE_KERNEL_EA_MULTI, bStartsSignalled, NULL);
		Asura_Assert(m_iEventId >= 0, "sceKernelCreateEventFlag failed");
	}

	~Asura_Platform_SyncEvent()
	{
#ifdef ASURA_ASSERT
		int iRet = 
#endif
		sceKernelDeleteEventFlag(m_iEventId);
		Asura_Assert(iRet == SCE_KERNEL_ERROR_OK, "sceKernelDeleteEventFlag failed");
	}

protected:

	int m_iEventId;
};

class Asura_Platform_Semaphore
{
public:

	Asura_Platform_Semaphore( const char* szName, u_int uInitialCount, u_int uMaxCount )
	{
		// TODO 
	}

	~Asura_Platform_Semaphore()
	{
		// TODO 
	}

protected:


};

// E N D   F I L E   W R A P P E R ///////////////////////////////////////////

#endif // #ifndef ___ASURA_PLATFORM_MULTITHREADTYPES_H___
