]>
git.saurik.com Git - apple/icu.git/blob - icuSources/common/mutex.h
2 ******************************************************************************
4 * Copyright (C) 1997-2013, International Business Machines
5 * Corporation and others. All Rights Reserved.
7 ******************************************************************************
9 //----------------------------------------------------------------------------
12 // Lightweight C++ wrapper for umtx_ C mutex functions
14 // Author: Alan Liu 1/31/97
16 // 06/04/97 helena Updated setImplementation as per feedback from 5/21 drop.
17 // 04/07/1999 srl refocused as a thin wrapper
19 //----------------------------------------------------------------------------
23 #include "unicode/utypes.h"
24 #include "unicode/uobject.h"
29 //----------------------------------------------------------------------------
30 // Code within that accesses shared static or global data should
31 // should instantiate a Mutex object while doing so. You should make your own
32 // private mutex where possible.
38 // void Function(int arg1, int arg2)
40 // static Object* foo; // Shared read-write object
41 // Mutex mutex(&myMutex); // or no args for the global lock
43 // // When 'mutex' goes out of scope and gets destroyed here, the lock is released
46 // Note: Do NOT use the form 'Mutex mutex();' as that merely forward-declares a function
47 // returning a Mutex. This is a common mistake which silently slips through the
51 class U_COMMON_API Mutex
: public UMemory
{
53 inline Mutex(UMutex
*mutex
= NULL
);
59 Mutex(const Mutex
&other
); // forbid copying of this class
60 Mutex
&operator=(const Mutex
&other
); // forbid copying of this class
63 inline Mutex::Mutex(UMutex
*mutex
)
69 inline Mutex::~Mutex()