home *** CD-ROM | disk | FTP | other *** search
/ AmigActive 6 / AACD06.ISO / AACD / Programming / ICU / src / icu / source / common / umutex.h < prev    next >
Encoding:
C/C++ Source or Header  |  1999-10-19  |  2.3 KB  |  75 lines

  1. /*
  2. *******************************************************************************
  3. *                                                                             *
  4. * COPYRIGHT:                                                                  *
  5. *   (C) Copyright Taligent, Inc.,  1997                                       *
  6. *   (C) Copyright International Business Machines Corporation,  1997-1999     *
  7. *   Licensed Material - Program-Property of IBM - All Rights Reserved.        *
  8. *   US Government Users Restricted Rights - Use, duplication, or disclosure   *
  9. *   restricted by GSA ADP Schedule Contract with IBM Corp.                    *
  10. *                                                                             *
  11. *******************************************************************************
  12. *
  13. * File UMUTEX.H
  14. *
  15. * Modification History:
  16. *
  17. *   Date        Name        Description
  18. *   04/02/97  aliu        Creation.
  19. *   04/07/99  srl         rewrite - C interface, multiple mutices
  20. *   05/13/99  stephen     Changed to umutex (from cmutex)
  21. ********************************************************************************
  22. */
  23.  
  24. #ifndef UMUTEX_H
  25. #define UMUTEX_H
  26.  
  27. #include "utypes.h"
  28.  
  29. #ifndef XP_CPLUSPLUS
  30. typedef void * Mutex;
  31. #endif
  32.  
  33. /*
  34.  * Code within this library which accesses protected data should
  35.  * instantiate a Mutex object while doing so.  Notice that there is
  36.  * only one coarse-grained lock which applies to this entire library,
  37.  * so keep locking short and sweet.
  38.  *
  39.  * For example:
  40.  *
  41.  * void Function(int arg1, int arg2)
  42.  * {
  43.  *   static Object* foo; // Shared read-write object
  44.  *   Mutex mutex;
  45.  *   foo->Method();
  46.  *   // When 'mutex' goes out of scope and gets destroyed here
  47.  *   // the lock is released
  48.  * }
  49.  *
  50.  * Note: Do NOT use the form 'Mutex mutex();' as that merely
  51.  * forward-declares a function returning a Mutex. This is a common
  52.  * mistake which silently slips through the compiler!!  */
  53.  
  54.  
  55. /* Mutex data type. */
  56. typedef void *UMTX;
  57.  
  58. /* Lock a mutex. Pass in NULL if you want the (ick) Single Global
  59.    Mutex. */
  60. U_CAPI void  U_EXPORT2 umtx_lock   ( UMTX* mutex ); 
  61.  
  62. /* Unlock a mutex. Pass in NULL if you want the single global
  63.    mutex. */
  64. U_CAPI void U_EXPORT2 umtx_unlock ( UMTX* mutex );
  65.  
  66. /* Initialize a mutex. Use it this way:
  67.    umtx_init( &aMutex ); */
  68. U_CAPI void U_EXPORT2 umtx_init   ( UMTX* mutex );
  69.  
  70. #endif /*_CMUTEX*/
  71. /*eof*/
  72.  
  73.  
  74.  
  75.