1999-08-16 21:50:52 +00:00
|
|
|
/*
|
1999-12-09 23:27:55 +00:00
|
|
|
**********************************************************************
|
|
|
|
* Copyright (C) 1997-1999, International Business Machines
|
|
|
|
* Corporation and others. All Rights Reserved.
|
|
|
|
**********************************************************************
|
1999-08-16 21:50:52 +00:00
|
|
|
*
|
|
|
|
* File UMUTEX.H
|
|
|
|
*
|
|
|
|
* Modification History:
|
|
|
|
*
|
|
|
|
* Date Name Description
|
|
|
|
* 04/02/97 aliu Creation.
|
|
|
|
* 04/07/99 srl rewrite - C interface, multiple mutices
|
|
|
|
* 05/13/99 stephen Changed to umutex (from cmutex)
|
|
|
|
********************************************************************************
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef UMUTEX_H
|
|
|
|
#define UMUTEX_H
|
|
|
|
|
|
|
|
#include "utypes.h"
|
|
|
|
|
|
|
|
#ifndef XP_CPLUSPLUS
|
|
|
|
typedef void * Mutex;
|
|
|
|
#endif
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Code within this library which accesses protected data should
|
|
|
|
* instantiate a Mutex object while doing so. Notice that there is
|
|
|
|
* only one coarse-grained lock which applies to this entire library,
|
|
|
|
* so keep locking short and sweet.
|
|
|
|
*
|
|
|
|
* For example:
|
|
|
|
*
|
|
|
|
* void Function(int arg1, int arg2)
|
|
|
|
* {
|
|
|
|
* static Object* foo; // Shared read-write object
|
|
|
|
* Mutex mutex;
|
|
|
|
* foo->Method();
|
|
|
|
* // When 'mutex' goes out of scope and gets destroyed here
|
|
|
|
* // the lock is released
|
|
|
|
* }
|
|
|
|
*
|
|
|
|
* Note: Do NOT use the form 'Mutex mutex();' as that merely
|
|
|
|
* forward-declares a function returning a Mutex. This is a common
|
|
|
|
* mistake which silently slips through the compiler!! */
|
|
|
|
|
|
|
|
|
|
|
|
/* Lock a mutex. Pass in NULL if you want the (ick) Single Global
|
|
|
|
Mutex. */
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 umtx_lock ( UMTX* mutex );
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/* Unlock a mutex. Pass in NULL if you want the single global
|
|
|
|
mutex. */
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 umtx_unlock ( UMTX* mutex );
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
/* Initialize a mutex. Use it this way:
|
|
|
|
umtx_init( &aMutex ); */
|
1999-10-18 23:44:20 +00:00
|
|
|
U_CAPI void U_EXPORT2 umtx_init ( UMTX* mutex );
|
1999-08-16 21:50:52 +00:00
|
|
|
|
|
|
|
#endif /*_CMUTEX*/
|
|
|
|
/*eof*/
|
|
|
|
|
|
|
|
|
|
|
|
|