ZFFramework
 
Loading...
Searching...
No Matches
ZFCoreMutex.h
Go to the documentation of this file.
1
5
6#ifndef _ZFI_ZFCoreMutex_h_
7#define _ZFI_ZFCoreMutex_h_
8
12
14typedef void (*ZFCoreMutexImplCallbackLock)(ZF_IN void *token);
16typedef void (*ZFCoreMutexImplCallbackUnlock)(ZF_IN void *token);
17
18extern ZFLIB_ZFCore void *_ZFP_ZFCoreMutexImplObject;
19extern ZFLIB_ZFCore ZFCoreMutexImplCallbackLock _ZFP_ZFCoreMutexImplLock;
20extern ZFLIB_ZFCore ZFCoreMutexImplCallbackUnlock _ZFP_ZFCoreMutexImplUnlock;
21
26 ZF_IN void *implObject
29 ) {
30 _ZFP_ZFCoreMutexImplObject = implObject;
31 _ZFP_ZFCoreMutexImplLock = implLock;
32 _ZFP_ZFCoreMutexImplUnlock = implUnlock;
33}
34
36inline void *ZFCoreMutexImplGetObject(void) {return _ZFP_ZFCoreMutexImplObject;}
38inline ZFCoreMutexImplCallbackLock ZFCoreMutexImplGetLock(void) {return _ZFP_ZFCoreMutexImplLock;}
40inline ZFCoreMutexImplCallbackUnlock ZFCoreMutexImplGetUnlock(void) {return _ZFP_ZFCoreMutexImplUnlock;}
41
43inline zfbool ZFCoreMutexImplAvailable(void) {return (_ZFP_ZFCoreMutexImplObject != zfnull);}
44
45// ============================================================
51#define ZFCoreMutexLock() \
52 do { \
53 if(_ZFP_ZFCoreMutexImplObject) { \
54 _ZFP_ZFCoreMutexImplLock(_ZFP_ZFCoreMutexImplObject); \
55 } \
56 } while(zffalse)
57
58#define ZFCoreMutexUnlock() \
59 do { \
60 if(_ZFP_ZFCoreMutexImplObject) { \
61 _ZFP_ZFCoreMutexImplUnlock(_ZFP_ZFCoreMutexImplObject); \
62 } \
63 } while(zffalse)
64
79
95#define ZFCoreMutexLocker() ZFCoreMutexLockerHolder _ZFP_ZFCoreMutexLocker_hold
96
97#if 0
98 #undef ZFCoreMutexLock
99 #define ZFCoreMutexLock()
100 #undef ZFCoreMutexUnlock
101 #define ZFCoreMutexUnlock()
102 #undef ZFCoreMutexLocker
103 #define ZFCoreMutexLocker()
104#endif
105
107
108#endif // #ifndef _ZFI_ZFCoreMutex_h_
109
#define ZFLIB_ZFCore
used to export symbols
Definition ZFCoreEnvDef.h:30
void(* ZFCoreMutexImplCallbackUnlock)(void *token)
mutex impl
Definition ZFCoreMutex.h:16
ZFCoreMutexImplCallbackUnlock ZFCoreMutexImplGetUnlock(void)
see ZFCoreMutexImplSet
Definition ZFCoreMutex.h:40
zfbool ZFCoreMutexImplAvailable(void)
see ZFCoreMutexImplSet
Definition ZFCoreMutex.h:43
void ZFCoreMutexImplSet(void *implObject, ZFCoreMutexImplCallbackLock implLock, ZFCoreMutexImplCallbackUnlock implUnlock)
ZFCoreMutexLock's implementation, change with caution
Definition ZFCoreMutex.h:25
void(* ZFCoreMutexImplCallbackLock)(void *token)
mutex impl
Definition ZFCoreMutex.h:14
void * ZFCoreMutexImplGetObject(void)
see ZFCoreMutexImplSet
Definition ZFCoreMutex.h:36
#define ZFCoreMutexUnlock()
see ZFCoreMutexLock
Definition ZFCoreMutex.h:58
ZFCoreMutexImplCallbackLock ZFCoreMutexImplGetLock(void)
see ZFCoreMutexImplSet
Definition ZFCoreMutex.h:38
#define ZFCoreMutexLock()
internal use only
Definition ZFCoreMutex.h:51
types for ZFFramework
#define zfclassLikePOD
shows the class is not a POD type, but you may use it like a POD except memset it to 0
Definition ZFCoreTypeDef_ClassType.h:41
#define ZF_IN
dummy macro that shows the param used as required input
Definition ZFCoreTypeDef_ClassType.h:180
types for ZFFramework
_ZFT_t_zfbool zfbool
bool type
Definition ZFCoreTypeDef_CoreType.h:103
#define zfnull
same as NULL, defined for future use
Definition ZFCoreTypeDef_CoreType.h:88
#define ZF_NAMESPACE_GLOBAL_BEGIN
begin namespace ZFFramework
Definition ZFNamespace.h:97
#define ZF_NAMESPACE_GLOBAL_END
end namespace ZFFramework
Definition ZFNamespace.h:98
see ZFCoreMutexLocker
Definition ZFCoreMutex.h:68