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

📄 rvlock.h

📁 基于h323协议的软phone
💻 H
字号:
/***********************************************************************
Filename   : rvlock.h
Description: rvlock header file
************************************************************************
      Copyright (c) 2001,2002 RADVISION Inc. and RADVISION Ltd.
************************************************************************
NOTICE:
This document contains information that is confidential and proprietary
to RADVISION Inc. and RADVISION Ltd.. No part of this document may be
reproduced in any form whatsoever without written prior approval by
RADVISION Inc. or RADVISION Ltd..

RADVISION Inc. and RADVISION Ltd. reserve the right to revise this
publication and make changes without obligation to notify any person of
such revisions or changes.
***********************************************************************/
/*$
{package:
	{name: Lock}
	{superpackage: CCore}
	{include: rvlock.h}
	{description:	
		{p: This module provides non-recursive locking functions to use specifically
			for locking code sections.}
	}
}
$*/
#ifndef RV_LOCK_H
#define RV_LOCK_H

#include "rvccore.h"

#if !defined(RV_LOCK_TYPE) || ((RV_LOCK_TYPE != RV_LOCK_SOLARIS) && \
    (RV_LOCK_TYPE != RV_LOCK_LINUX) && (RV_LOCK_TYPE != RV_LOCK_VXWORKS) && \
    (RV_LOCK_TYPE != RV_LOCK_PSOS) && (RV_LOCK_TYPE != RV_LOCK_WIN32_MUTEX) && \
    (RV_LOCK_TYPE != RV_LOCK_WIN32_CRITICAL) && (RV_LOCK_TYPE != RV_LOCK_MANUAL) && \
    (RV_LOCK_TYPE != RV_LOCK_NONE))
#error RV_LOCK_TYPE not set properly
#endif

#if !defined(RV_LOCK_ATTRIBUTE_DEFAULT)
#error RV_LOCK_ATTRIBUTE_DEFAULT not set properly
#endif

/*$
{type:
	{name: RvLock}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:	
		{p: A non-recursive lock object.}
	}
}
$*/
/*$
{type:
	{name: RvLockAttr}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:	
		{p: OS specific attributes and options used for locks. See definitions in rvlock.h
			along with the default values in rvccoreconfig.h for more information.}
	}
}
$*/
/* Get include files and define RvLock and RvLockAttr types for each OS */
#if (RV_LOCK_TYPE == RV_LOCK_SOLARIS) || (RV_LOCK_TYPE == RV_LOCK_LINUX)
/* They're both posix, but the attributes are not the same, so we need 2 settings */
#include <pthread.h>
typedef pthread_mutex_t RvLock;
typedef struct {
	/* These correspond to attributes in the pthread_mutexattr struct that we let users set */
	int kind; /* solaris calls it type, never set it to recursive */
#if (RV_LOCK_TYPE == RV_LOCK_TYPE)
	/* Solaris specific options */
	int pshared;
	int protocol;
#endif
} RvLockAttr;
#endif
#if (RV_LOCK_TYPE == RV_LOCK_VXWORKS)
#include <vxworks.h>
#include <semLib.h>
typedef SEM_ID RvLock;
typedef int RvLockAttr; /* options to semBCreate */
#endif
#if (RV_LOCK_TYPE == RV_LOCK_PSOS)
#include <psos.h>
typedef unsigned long RvLock;
typedef unsigned long RvLockAttr; /* flags to mu_create (Don't set RECURSIVE/NORECURSIVE) */
#endif
#if (RV_LOCK_TYPE == RV_LOCK_WIN32_MUTEX)
#include <windows.h>
typedef HANDLE RvLock;
typedef int RvLockAttr; /* not used */
#endif
#if (RV_LOCK_TYPE == RV_LOCK_WIN32_CRITICAL)
#include <windows.h>
typedef CRITICAL_SECTION RvLock;
typedef DWORD RvLockAttr; /* spin count (use only on Win2000 and newer) */
#endif
#if (RV_LOCK_TYPE == RV_LOCK_MANUAL)
#include "rvsemaphore.h"
typedef RvSemaphore RvLock;
typedef int RvLockAttr; /* not used, any seamphore attributes will apply */
#endif
#if (RV_LOCK_TYPE == RV_LOCK_NONE)
typedef RvInt RvLock;    /* Dummy types, used to prevent warnings. */
typedef RvInt RvLockAttr; /* not used */
#endif

#if defined(__cplusplus)
extern "C" {
#endif 

/* Prototypes: See documentation blocks below for details. */
RvStatus RvLockInit(void);
RvStatus RvLockEnd(void);
#if (RV_LOCK_TYPE != RV_LOCK_NONE)
RVCOREAPI
RvStatus RVCALLCONV RvLockConstruct(RvLock *lock);
RVCOREAPI
RvStatus RVCALLCONV RvLockDestruct(RvLock *lock);
RVCOREAPI
RvStatus RVCALLCONV RvLockGet(RvLock *lock);
RVCOREAPI
RvStatus RVCALLCONV RvLockRelease(RvLock *lock);
RvStatus RvLockSetAttr(RvLockAttr *attr);
#else
/* If none is set then none of these functions do anything */
#define RvLockConstruct(_l) (*(_l) = RV_OK)
#define RvLockDestruct(_l) (*(_l) = RV_OK)
#define RvLockGet(_l) (*(_l) = RV_OK)
#define RvLockRelease(_l) (*(_l) = RV_OK)
#define RvLockSetAttr(_l) (*(_l) = RV_OK)
#endif

#if defined(RV_TEST_CODE)
void RvLockTest(void);
#endif /* RV_TEST_CODE */

#if defined(__cplusplus)
}
#endif 

/* Function Documentation */
/*$
{function scope="protected":
	{name: RvLockInit}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Initializes the Lock module. Must be called once (and
			only once) before any other functions in the module are called.}
	}
	{proto: RvStatus RvLockInit(void);}
	{returns: RV_OK if successful otherwise an error code.}
}
$*/
/*$
{function scope="protected":
	{name: RvLockEnd}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Shuts down the Lock module. Must be called once (and
			only once) when no further calls to this module will be made.}
	}
	{proto: RvStatus RvLockEnd(void);}
	{returns: RV_OK if successful otherwise an error code.}
}
$*/
/*$
{function:
	{name: RvLockConstruct}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Creates a locking object.}
	}
	{proto: RvStatus RvLockConstruct(RvLock *lock);}
	{params:
		{param: {n: lock}  {d: Pointer to lock object to be constructed.}}
	}
	{returns: RV_OK if successful otherwise an error code.}
}
$*/
/*$
{function:
	{name: RvLockDestruct}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Destroys a locking object.}
	}
	{proto: RvStatus RvLockDestruct(RvLock *lock);}
	{params:
		{param: {n: lock}  {d: Pointer to lock object to be destructed.}}
	}
	{returns: RV_OK if successful otherwise an error code.}
	{notes:
		{note: Never destroy a lock object which has a thread suspended on it.}
	}
}
$*/
/*$
{function:
	{name: RvLockGet}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Aquires a lock. Will suspend the calling task until the lock is available.}
	}
	{proto: RvStatus RvLockGet(RvLock *lock);}
	{params:
		{param: {n: lock}  {d: Pointer to lock object to be aquired.}}
	}
	{returns: RV_OK if successful otherwise an error code.}
}
$*/
/*$
{function:
	{name: RvLockRelease}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Releases a lock.}
	}
	{proto: RvStatus RvLockRelease(RvLock *lock);}
	{params:
		{param: {n: lock}  {d: Pointer to lock object to be released.}}
	}
	{returns: RV_OK if successful otherwise an error code.}
	{notes:
		{note: Do not release a lock more times than it has been aquired.}
	}
}
$*/
/*$
{function:
	{name: RvLockSetAttr}
	{superpackage: Lock}
	{include: rvlock.h}
	{description:
		{p: Sets the options and attributes to be used when creating and using lock objects.}
	}
	{proto: RvStatus RvLockSetAttr(RvLockAttr *attr);}
	{params:
		{param: {n: attr}  {d: Pointer to OS speicific lock attributes to begin using.}}
	}
	{returns: RV_OK if successful otherwise an error code.}
	{notes:
		{note: Non-reentrant function. Do not call when other threads may be calling rvlock functions.}
		{note: These attributes are global and will effect all lock functions called thereafter.}
		{note: The default values for these attributes are set in rvccoreconfig.h.}
	}
}
$*/

#endif

⌨️ 快捷键说明

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