⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xos_threads.h.svn-base

📁 brew头文件分析
💻 SVN-BASE
字号:
//**************************************************************
//Copyright (C), 2008-2008, AnyLook Co., Ltd.
//File name:    xBIOS_Threads.h
//Author:       AnyLook
//Version:      1.0
//Date:       2008/07/31
//Description:
//    xOS Include file
//Others: 
//Function List: 
//<Name>        <desc>
//Simple        
//History: 
//<author>      <time>      <version >  <desc>
// AnyLook     2008/07/31       1.0       build this moudle  
//**************************************************************


#ifndef _xOS_THREADS_H
#define _xOS_THREADS_H

#ifdef __cplusplus
extern "C" {
#endif

#include "xOS_Threads_VTBL.h"

//Thread
#ifdef xOS_PASSED_BEGINTHREAD_ENDTHREAD
static INLINE xOS_Thread *xOS_Thread_CreateThread(int (xOSCALL *fn)(void *), void *data, pfnxOS_CurrentBeginThread pfnBeginThread, pfnxOS_CurrentEndThread pfnEndThread)
{
	if (GETTHREADS(g_pxOSList))
	{
		return GETTHREADS(g_pxOSList)->CreateThread(fn, data, pfnBeginThread, pfnEndThread);
	}
	return 0;
}
#else
static INLINE xOS_Thread  *xOS_Thread_CreateThread(int (xOSCALL *fn)(void *), void *data)
{
	if (GETTHREADS(g_pxOSList))
	{
		return GETTHREADS(g_pxOSList)->CreateThread(fn, data);
	}
	return 0;
}
#endif


static INLINE Uint32 xOS_Thread_ThreadID(void)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->ThreadID();
    }
    return 0;
}


static INLINE Uint32 xOS_Thread_GetThreadID(xOS_Thread *thread)    //xOS Only 
{
   if (GETTHREADS(g_pxOSList))     
   {
        return GETTHREADS(g_pxOSList)->GetThreadID(thread);
   }
   return 0;
}


static INLINE void xOS_Thread_WaitThread(xOS_Thread *thread, int *status)
{
	if (GETTHREADS(g_pxOSList))
    {
		 GETTHREADS(g_pxOSList)->WaitThread(thread, status);
    }
    return ;
}

static INLINE void  xOS_Thread_KillThread(xOS_Thread *thread)
{
	if (GETTHREADS(g_pxOSList))
    {
		GETTHREADS(g_pxOSList)->KillThread(thread);
    }
    return ;
}


//mutex
static INLINE xOS_mutex  *xOS_Thread_CreateMutex(void)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->CreateMutex();
    }
     return 0;
}

static INLINE void  xOS_Thread_DestroyMutex(xOS_mutex *mutex)
{
	if (GETTHREADS(g_pxOSList))
    {
		GETTHREADS(g_pxOSList)->DestroyMutex(mutex);
    }
    return ;
}

static INLINE int xOS_Thread_mutexP(xOS_mutex *mutex)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->mutexP(mutex);
    }
    return 0;
}

static INLINE int xOS_Thread_mutexV(xOS_mutex *mutex)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->mutexV(mutex);
    }
    return 0;
}


static INLINE int xOS_Thread_LockMutex(xOS_mutex *mutex)        //xOS Only
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->LockMutex(mutex);
    }
    return 0;
}

static INLINE int xOS_Thread_UnlockMutex(xOS_mutex *mutex)      //xOS Only
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->UnlockMutex(mutex);
    }
    return 0;
}



//sema
static INLINE xOS_sem	* xOS_Thread_CreateSemaphore(Uint32 initial_value)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->CreateSemaphore(initial_value);
    }
    return 0;
}

static INLINE void     xOS_Thread_DestroySemaphore(xOS_sem *sem)
{
	if (GETTHREADS(g_pxOSList))
    {
		GETTHREADS(g_pxOSList)->DestroySemaphore(sem);
    }
    return ;
}

static INLINE int xOS_Thread_SemWait(xOS_sem *sem)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->SemWait(sem);
    }
    return 0;
}

static INLINE int xOS_Thread_SemTryWait(xOS_sem *sem)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->SemTryWait(sem);
    }
    return 0;
}

static INLINE int xOS_Thread_SemWaitTimeout(xOS_sem *sem, Uint32 timeout)
{
	if (GETTHREADS(g_pxOSList))
    {
		
		return GETTHREADS(g_pxOSList)->SemWaitTimeout(sem,timeout);
    }
    return 0;
}

static INLINE int xOS_Thread_SemPost(xOS_sem *sem)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->SemPost(sem);
    }
    return 0;
}


static INLINE Uint32 xOS_Thread_SemValue(xOS_sem *sem)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->SemValue(sem);
    }
    return 0;
}


//xOS Only

static INLINE xOS_cond *xOS_Thread_CreateCond(void)
{
	if (GETTHREADS(g_pxOSList))
    {
		return GETTHREADS(g_pxOSList)->CreateCond();
    }
    return 0;
}


static INLINE void  xOS_Thread_DestroyCond(xOS_cond *cond)
{
    if (GETTHREADS(g_pxOSList))
    {
       GETTHREADS(g_pxOSList)->DestroyCond(cond);

    }
    return;
}


static INLINE int  xOS_Thread_CondSignal(xOS_cond *cond)
{
    if (GETTHREADS(g_pxOSList))
    {
        return GETTHREADS(g_pxOSList)->CondSignal(cond);

    }
    return 0;
}


static INLINE int  xOS_Thread_CondBroadcast(xOS_cond *cond)
{
    if (GETTHREADS(g_pxOSList))
    {
        return GETTHREADS(g_pxOSList)->CondBroadcast(cond);
    }
    return 0;
}

static INLINE int  xOS_Thread_CondWait(xOS_cond *cond, xOS_mutex *mutex)
{
    if (GETTHREADS(g_pxOSList))
    {
        return GETTHREADS(g_pxOSList)->CondWait(cond, mutex);
    }
    return 0;
}

static INLINE int  xOS_Thread_CondWaitTimeout(xOS_cond *cond, xOS_mutex *mutex, Uint32 ms)
{
    if (GETTHREADS(g_pxOSList))
    {
        return GETTHREADS(g_pxOSList)->CondWaitTimeout(cond, mutex, ms);
    }
    return 0;
}


#ifdef __cplusplus
}
#endif

#endif //_xOS_THREADS_H

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -