亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频

? 歡迎來到蟲蟲下載站! | ?? 資源下載 ?? 資源專輯 ?? 關于我們
? 蟲蟲下載站

?? rvthreadinstance.c

?? 基于h323協議的軟phone
?? C
字號:
/***********************************************************************
Copyright (c) 2002 RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Ltd.. No part of this document may be reproduced in any
form whatsoever without written prior approval by RADVISION Ltd..
RADVISION Ltd. reserve the right to revise this publication and make
changes without obligation to notify any person of such revisions or
changes.
***********************************************************************/

/*-----------------------------------------------------------------------*/
/*                        INCLUDE HEADER FILES                           */
/*-----------------------------------------------------------------------*/

#include "rvstdio.h"
#include "rvmemory.h"
#include "rvthread.h"
#include "rvthreadinstance.h"


#ifdef __cplusplus
extern "C" {
#endif

/*-----------------------------------------------------------------------*/
/*                           TYPE DEFINITIONS                            */
/*-----------------------------------------------------------------------*/

/* Information about a specific object */
typedef struct
{
    const RvChar*               objectName; /* Name of the object */
    ThreadInstanceDeleteFunc    deleteFunc; /* Deletion function to use */
    void*                       context; /* Context for the deletion function */

    void*                       objectPtr; /* Created object's pointer */
    RvUint32                    count; /* Number of times this object was constructed */
    RvSize_t                    amountUsed; /* Number of sub-objects we needed */
    RvSize_t                    amountAllocated; /* Number of sub-objects we have allocated */
} ThreadInstanceObjectData;


/*-----------------------------------------------------------------------*/
/*                           MODULE VARIABLES                            */
/*-----------------------------------------------------------------------*/


/*-----------------------------------------------------------------------*/
/*                        STATIC FUNCTIONS PROTOTYPES                    */
/*-----------------------------------------------------------------------*/

static void ThreadInstanceExitFunc(
    IN RvThread*    threadInfo,
    IN void*        context,
    IN RvUint32     index);



/*-----------------------------------------------------------------------*/
/*                           MODULE FUNCTIONS                            */
/*-----------------------------------------------------------------------*/


/******************************************************************************
 * ThreadInstanceInitObject
 * ----------------------------------------------------------------------------
 * General: Initialize a specific object instance, making sure it is only
 *          constructed once for each thread. Multiple calls to this function
 *          with the same arguments from the same thread will be discarded.
 * Return Value: RV_OK  - if successful.
 * ----------------------------------------------------------------------------
 * Arguments:
 * Input  : objectName      - The name of the constructed object.
 *          func            - Function for creation of the object. Only called once for
 *                            each thread (or if the amount of sub-objects needed is not
 *                            satisfied.
 *          context         - Context used for the creation function.
 *          amountNeeded    - Amount of sub-objects the initialized object should
 *                            support. Can be set to 0 if not relevant.
 * Output : objectPtr       - Pointer to the cosntructed object (as returned by the
 *                            creation function func).
 *          count           - Number of times this object was called for construction
 *                            in the current thread.
 *          index           - Index to use for faster access.
 *****************************************************************************/
RvStatus ThreadInstanceInitObject(
    IN  const RvChar*               objectName,
    IN  ThreadInstanceCreateFunc    func,
    IN  void*                       context,
    IN  RvSize_t                    amountNeeded,
    OUT void**                      objectPtr,
    OUT RvUint32*                   count,
    OUT RvUint32*                   index)
{
    ThreadInstanceObjectData* objData;
    RvStatus status;
    RvBool newVarCreated = RV_FALSE;
    RvUint32 tlsIndex;
    RvSize_t missing = 0;
    RvThread* curThread;

    /* First, make sure we have a thread object for this thread. */
    curThread = RvThreadCurrent();
    if (curThread == NULL)
    {
        static int appThreadNum = 0;
        RvChar threadName[20];

        /* Seems like we'll need to create one on our own. */
        status = RvMemoryAlloc(NULL, (void**)&curThread, sizeof(RvThread));
        if (status != RV_OK)
            return status;

        status = RvThreadConstructFromUserThread(curThread);
        if (status == RV_OK)
            status = RvThreadSetAutoDelete(curThread, RV_TRUE);
        if (status == RV_OK)
        {
            RvSprintf(threadName, "%d H323User", appThreadNum);
            status = RvThreadSetName(curThread, threadName);
        }

        if (status != RV_OK)
        {
            RvMemoryFree(curThread);
            return status;
        }
    }
    
    /* First, let's find the thread index of this object name */
    status = RvThreadFindVar((RvChar*)objectName, &tlsIndex);
    if (RvErrorGetCode(status) == RV_THREAD_WARNING_NOTFOUND)
    {
        /* Not found - create a new one */
        status = RvThreadCreateVar(ThreadInstanceExitFunc, (RvChar*)objectName, &tlsIndex);
        newVarCreated = RV_TRUE;
    }

    if (status != RV_OK)
        return status;

    /* Now that we have an index, let's see if we have a variable already set */
    status = RvThreadGetVar(tlsIndex, (void**)&objData);
    if (status != RV_OK)
        return status;

    if (objData == NULL)
    {
        /* Allocate a new object - first time for this thread */
        status = RvMemoryAlloc(NULL, (void**)&objData, sizeof(ThreadInstanceObjectData));
        if (status != RV_OK)
            return status;

        memset(objData, 0, sizeof(ThreadInstanceObjectData));
        objData->objectName = objectName;
        objData->context = context;

        /* Call the creation function */
        status = func(objectName, context, amountNeeded,
            &objData->objectPtr, &objData->amountAllocated, &objData->deleteFunc);

        if (status == RV_OK)
            status = RvThreadSetVar(tlsIndex, objData);

        if (status != RV_OK)
        {
            /* oops - couldn't create this object - let's ditch it */
            RvMemoryFree(objData);
            if (newVarCreated)
                RvThreadDeleteVar(tlsIndex);
            return status;
        }
    }
    else
    {
        /* Let's see if there are any vacant objects that we can use */
        if (amountNeeded > 0)
        {
            /* Seems like we're looking for some more space */
            if (objData->amountAllocated >= objData->amountUsed + amountNeeded)
            {
                /* Got more than needed */
                objData->amountUsed += amountNeeded;
            }
            else
            {
                RvSize_t allocated;

                /* Not enough... */
                missing = amountNeeded - (objData->amountAllocated - objData->amountUsed);

                /* Call the creation function to add some more sub-objects */
                status = func(objectName, NULL, missing,
                    &objData->objectPtr, &allocated, NULL);
                if (status != RV_OK)
                    return status;

                /* Now make sure we update the amount of sub-objects */
                objData->amountAllocated += allocated;
                objData->amountUsed += amountNeeded;
            }
        }
    }

    /* We've got another reference for this object */
    objData->count++;

    if (count != NULL)
        *count = objData->count;
    if (objectPtr != NULL)
        *objectPtr = objData->objectPtr;
    if (index != NULL)
        *index = tlsIndex;

    return RV_OK;
}


/******************************************************************************
 * ThreadInstanceGetObject
 * ----------------------------------------------------------------------------
 * General: Get the object that was initialized for the current thread.
 * Return Value: RV_OK  - if successful.
 * ----------------------------------------------------------------------------
 * Arguments:
 * Input  : index       - Index of the object as given by ThreadInstanceInitObject().
 * Output : objectPtr   - Object pointer initialized.
 *****************************************************************************/
RvStatus ThreadInstanceGetObject(
    IN  RvUint32    index,
    OUT void**      objectPtr)
{
    ThreadInstanceObjectData* objData;
    RvStatus status;

    /* Now let's get the object of the current thread */
    status = RvThreadGetVar(index, (void**)&objData);
    if (status != RV_OK)
        return status;

    if (objData == NULL)
        return RV_ERROR_BADPARAM; /* Seems like we called it from the wrong thread */

    *objectPtr = objData->objectPtr;

    return RV_OK;
}


/******************************************************************************
 * ThreadInstanceFindIndex
 * ----------------------------------------------------------------------------
 * General: Find the index of an object by its name.
 * Return Value: RV_OK  - if successful.
 * ----------------------------------------------------------------------------
 * Arguments:
 * Input  : objectName  - Name of the object we're looking for.
 * Output : index       - Index of the object
 *****************************************************************************/
RvStatus ThreadInstanceFindIndex(
    IN  const RvChar*   objectName,
    OUT RvUint32*       index)
{
    RvStatus status;
    RvUint32 tlsIndex;

    /* Let's find the thread index of this object name */
    status = RvThreadFindVar((RvChar*)objectName, &tlsIndex);
    if (RvErrorGetCode(status) == RV_THREAD_WARNING_NOTFOUND)
        return RV_ERROR_BADPARAM;

    if (status == RV_OK)
        *index = tlsIndex; /* found it */

    return status;
}


/******************************************************************************
 * ThreadInstanceEndObject
 * ----------------------------------------------------------------------------
 * General: Deinitialize a specific object instance, making sure it is only
 *          destructed once for each thread (when no one is referencing it).
 * Return Value: RV_OK  - if successful.
 * ----------------------------------------------------------------------------
 * Arguments:
 * Input  : index   - Index of the object as given by ThreadInstanceInitObject().
 *          amount  - Amount of subobjects we won't need from now on. Can be set to
 *                    0 if this should be discarded.
 * Output : count   - Number of times this object is still referenced.
 *****************************************************************************/
RvStatus ThreadInstanceEndObject(
    IN  RvUint32        index,
    IN  RvSize_t        amount,
    OUT RvUint32*       count)
{
    ThreadInstanceObjectData* objData;
    RvStatus status;

    /* Now let's get the object of the current thread */
    status = RvThreadGetVar(index, (void**)&objData);
    if (status != RV_OK)
        return status;

    if (objData == NULL)
        return RV_ERROR_BADPARAM; /* Seems like we called it from the wrong thread */

    objData->count--;
    if (count != NULL)
        *count = objData->count;

    if (objData->count == 0)
    {
        /* Seems like we have to delete this object */
        status = objData->deleteFunc(objData->objectName, objData->context, objData->objectPtr);
        RvMemoryFree(objData);
        RvThreadSetVar(index, NULL);
        return status;
    }
    else
    {
        /* Let's get rid of the amount of objects we don't need anymore */
        objData->amountUsed -= amount;
    }

    return RV_OK;
}





/*-----------------------------------------------------------------------*/
/*                           STATIC FUNCTIONS                            */
/*-----------------------------------------------------------------------*/


/******************************************************************************
 * ThreadInstanceExitFunc
 * ----------------------------------------------------------------------------
 * General: This exit function is called automatically when the thread is
 *          being destructed.
 * Return Value: RV_OK  - if successful.
 * ----------------------------------------------------------------------------
 * Arguments:
 * Input  : threadInfo  - Current thread information (the one being destructed)
 *          context     - Context used for this call
 *          index       - Variable index used
 * Output : none
 *****************************************************************************/
static void ThreadInstanceExitFunc(
    IN RvThread*    threadInfo,
    IN void*        context,
    IN RvUint32     index)
{
    ThreadInstanceObjectData* objData = (ThreadInstanceObjectData *)context;

    if (objData == NULL)
        return;

    if (objData->count > 0)
    {
        /* Kill this object */
        objData->deleteFunc(objData->objectName, objData->context, objData->objectPtr);
        RvMemoryFree(objData);
    }
}





#ifdef __cplusplus
}
#endif

?? 快捷鍵說明

復制代碼 Ctrl + C
搜索代碼 Ctrl + F
全屏模式 F11
切換主題 Ctrl + Shift + D
顯示快捷鍵 ?
增大字號 Ctrl + =
減小字號 Ctrl + -
亚洲欧美第一页_禁久久精品乱码_粉嫩av一区二区三区免费野_久草精品视频
国产美女在线精品| 日韩精品视频网站| 久久综合九色综合欧美亚洲| 欧美日韩日日骚| 在线观看免费一区| 欧美吻胸吃奶大尺度电影| 色天天综合色天天久久| caoporn国产一区二区| zzijzzij亚洲日本少妇熟睡| aa级大片欧美| 日本韩国视频一区二区| 在线精品视频一区二区三四 | 在线播放91灌醉迷j高跟美女| 日本乱码高清不卡字幕| 精品视频全国免费看| 在线不卡的av| 精品sm在线观看| 国产日韩成人精品| 亚洲精品中文在线影院| 亚洲国产视频一区二区| 日本网站在线观看一区二区三区 | 不卡av电影在线播放| 91香蕉视频污在线| 欧美精品国产精品| 精品国产a毛片| 亚洲图片另类小说| 热久久免费视频| 成人免费观看男女羞羞视频| 一本色道久久综合亚洲91| 91麻豆精品国产91久久久久久久久| 91麻豆精品91久久久久久清纯 | 国产精品美女久久久久久久网站| 亚洲免费电影在线| 免费观看在线综合色| 国产精品一区二区久激情瑜伽| 99精品视频一区| 欧美电影免费观看高清完整版在线 | 尤物av一区二区| 久久不见久久见中文字幕免费| eeuss鲁片一区二区三区在线看 | 蜜乳av一区二区三区| 成人激情电影免费在线观看| 欧美日产在线观看| 欧美国产精品一区二区三区| 午夜天堂影视香蕉久久| 成人免费的视频| 日韩色视频在线观看| 亚洲乱码中文字幕| 国产成人av影院| 欧美一区二区三区视频| 亚洲三级在线播放| 国产成人av一区| 日韩午夜在线影院| 亚瑟在线精品视频| 成人av在线播放网址| 精品乱码亚洲一区二区不卡| 天天综合日日夜夜精品| 91麻豆免费看| 亚洲欧美综合网| 丁香网亚洲国际| 久久综合色之久久综合| 免费欧美高清视频| 欧美日韩国产影片| 亚洲国产精品久久人人爱| 成人午夜视频福利| 国产人妖乱国产精品人妖| 久久精品国产99国产精品| 欧美日韩国产色站一区二区三区| 国产精品国产自产拍高清av王其| 国产在线精品一区二区夜色| 欧美一区午夜视频在线观看| 午夜不卡在线视频| 欧美日韩1234| 日韩高清在线电影| 精品国产乱码久久久久久久久| 首页综合国产亚洲丝袜| 欧美日韩亚洲综合在线 欧美亚洲特黄一级| 亚洲欧美自拍偷拍| 97久久精品人人澡人人爽| 欧美国产丝袜视频| 99久久99久久精品免费看蜜桃| 国产精品久久久久久久久久久免费看 | 中文字幕字幕中文在线中不卡视频| 国产伦精品一区二区三区视频青涩| 2020国产精品久久精品美国| 国产原创一区二区三区| 久久久99久久| 丁香婷婷综合激情五月色| 国产亚洲成aⅴ人片在线观看| 粉嫩在线一区二区三区视频| 国产精品你懂的在线欣赏| 99精品视频一区二区| 亚洲一区二区三区在线| 欧美高清一级片在线| 日韩精品乱码免费| 久久尤物电影视频在线观看| 国产成a人亚洲精品| 中文字幕综合网| 欧美日韩大陆一区二区| 久草热8精品视频在线观看| 久久久久亚洲蜜桃| 91在线精品秘密一区二区| 亚洲成人tv网| 久久综合久久综合九色| 91免费精品国自产拍在线不卡| 亚洲123区在线观看| 亚洲精品一区二区三区99| 91在线porny国产在线看| 天天影视涩香欲综合网| 亚洲国产精品二十页| 色综合久久久久久久| 精品无人区卡一卡二卡三乱码免费卡 | 日韩av不卡在线观看| www久久精品| 欧美中文字幕久久| 国产乱淫av一区二区三区| 亚洲免费av在线| 国产亚洲一二三区| 欧美日韩国产天堂| a在线欧美一区| 久久国产人妖系列| 亚洲男人的天堂av| 久久先锋资源网| 91精品午夜视频| 91国模大尺度私拍在线视频| 国产露脸91国语对白| 午夜精品福利一区二区三区av| 欧美高清在线一区| 欧美电视剧免费观看| 欧美四级电影在线观看| 波多野洁衣一区| 久久99精品国产麻豆不卡| 玉足女爽爽91| 中文字幕中文字幕在线一区 | 日韩女优毛片在线| 欧美午夜一区二区| 91色在线porny| 粉嫩13p一区二区三区| 久久精品国产77777蜜臀| 亚洲成人综合视频| 一区二区三区四区在线| 亚洲婷婷综合久久一本伊一区 | 成人高清免费在线播放| 国产夜色精品一区二区av| 欧美性猛交xxxx乱大交退制版| 大胆欧美人体老妇| 国产成人自拍在线| 国产麻豆精品视频| 国产盗摄视频一区二区三区| 六月婷婷色综合| 老司机午夜精品| 久草精品在线观看| 国产一区在线观看视频| 久久se精品一区精品二区| 久久99精品视频| 国产在线精品一区二区三区不卡| 九九国产精品视频| 国产呦精品一区二区三区网站| 激情综合网天天干| 国产酒店精品激情| 成人一区二区在线观看| 成人视屏免费看| 99久久精品国产麻豆演员表| 91啪九色porn原创视频在线观看| 91在线视频播放| 欧美色综合网站| 91精品国产色综合久久不卡电影| 7777精品伊人久久久大香线蕉的 | 综合av第一页| 亚洲一区二区在线视频| 亚洲成a人v欧美综合天堂| 日韩黄色一级片| 国产一区二区三区美女| 国产精品123| 在线免费观看一区| 日韩一级大片在线观看| 国产三区在线成人av| 国产精品久久毛片| 午夜欧美大尺度福利影院在线看| 日韩av一区二区在线影视| 国产精品一级在线| 色成年激情久久综合| 欧美一区二区三区免费在线看| 精品动漫一区二区三区在线观看| 欧美国产日韩一二三区| 亚洲国产sm捆绑调教视频| 狠狠色丁香婷婷综合| 91免费精品国自产拍在线不卡| 欧美一区二区三区免费| 国产精品视频在线看| 免费不卡在线视频| 99精品视频在线观看| 欧美精选在线播放| 国产精品人人做人人爽人人添| 亚洲一二三区在线观看| 国产成人午夜99999| 5858s免费视频成人| 中文字幕中文字幕在线一区| 日韩精品一区第一页| jlzzjlzz欧美大全|