sync.h
来自「This is a resource based on j2me embedde」· C头文件 代码 · 共 549 行 · 第 1/2 页
H
549 行
CVMsysMonitorEnter(CVMExecEnv *ee, CVMSysMonitor* m);extern voidCVMsysMonitorExit(CVMExecEnv *ee, CVMSysMonitor* m);extern CVMBoolCVMsysMonitorNotify(CVMExecEnv *ee, CVMSysMonitor* m);extern CVMBoolCVMsysMonitorNotifyAll(CVMExecEnv *ee, CVMSysMonitor* m);extern CVMWaitStatusCVMsysMonitorWait(CVMExecEnv *ee, CVMSysMonitor* m, CVMInt64 millis);#define CVMsysMonitorOwner(m) CVMreentrantMutexOwner(&(m)->rmutex)#define CVMsysMonitorCount(m) CVMreentrantMutexCount(&(m)->rmutex)#ifdef CVM_THREAD_BOOST#define CVMsysMonitorAcquireMutex(ee, m) \ CVMreentrantMutexAcquire((ee), &(m)->rmutex)#else#define CVMsysMonitorSetMutexOwner(ee, m, o) \ CVMreentrantMutexSetOwner((ee), &(m)->rmutex, (o))#endif#define CVMsysMonitorTryEnter(ee, m) \ CVMreentrantMutexTryLock((ee), &(m)->rmutex)#define CVMsysMonitorEnterUnsafe(ee, m) \{ \ CVMreentrantMutexLockUnsafe((ee), &(m)->rmutex); \}#define CVMsysMonitorEnterSafe(ee, m) \{ \ CVMassert(CVMD_isgcSafe((ee))); \ CVMreentrantMutexLock((ee), &(m)->rmutex); \}#define CVMsysMonitorEnter(ee, m) CVMsysMonitorEnterSafe((ee), (m))#define CVMsysMonitorExit(ee, m) \{ \ CVMreentrantMutexUnlock((ee), &(m)->rmutex); \}/*===========================================================================*/#if defined(CVM_JVMPI) || defined(CVM_JVMTI)/* CVM lock type necessary for JVMPI/JVMTI: */enum { CVM_LOCKTYPE_UNKNOWN = 0, /* Reserved to indicate an illegal type. */ CVM_LOCKTYPE_OBJ_MONITOR, CVM_LOCKTYPE_NAMED_SYSMONITOR};#endifstruct CVMProfiledMonitor { CVMSysMonitor _super;#if defined(CVM_JVMPI) || defined(CVM_JVMTI) CVMUint8 type; CVMUint32 contentionCount; CVMProfiledMonitor *next; CVMProfiledMonitor **previousPtr;#endif};#if defined(CVM_JVMPI) || defined(CVM_JVMTI)/* Purpose: Constructor. */extern CVMBoolCVMprofiledMonitorInit(CVMProfiledMonitor *self, CVMExecEnv *owner, CVMUint32 count, CVMUint8 lockType);#else/* inline CVMBool CVMprofiledMonitorInit(CVMProfiledMonitor *self, CVMExecEnv *owner, CVMUint32 count)); */#define CVMprofiledMonitorInit(self, owner, count, lockType) \ CVMsysMonitorInit(&(self)->_super, (owner), (count))#endif/* Purpose: Destructor. *//* inline void CVMprofiledMonitorDestroy(CVMProfiledMonitor *self); */#define CVMprofiledMonitorDestroy(self) \ CVMsysMonitorDestroy(&(self)->_super)#if defined(CVM_JVMPI) || defined(CVM_JVMTI)/* Purpose: Gets the type of the CVMProfiledMonitor. *//* inline CVMUint8 CVMprofiledMonitorGetType(CVMProfiledMonitor *self); */#define CVMprofiledMonitorGetType(self) \ ((self)->type)/* Purpose: Sets the type of the CVMProfiledMonitor. *//* inline void CVMprofiledMonitorGetType(CVMProfiledMonitor *self, CVMUint8 type); */#define CVMprofiledMonitorSetType(self, _type) \ ((self)->type = (_type))#endif /* CVM_JVMPI *//* Purpose: Enters the monitor. *//* inline void CVMprofiledMonitorEnter(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorEnter(self, currentEE, isRaw) \ CVMprofiledMonitorEnterSafe((self), (currentEE), (isRaw))/* Purpose: Exits the monitor. */#if defined(CVM_JVMPI) || defined(CVM_JVMTI)extern voidCVMprofiledMonitorExit(CVMProfiledMonitor *self, CVMExecEnv *currentEE);#else /* !CVM_JVMPI *//* inline void CVMprofiledMonitorExit(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorExit(self, currentEE) \ CVMsysMonitorExit((currentEE), (&(self)->_super))#endif /* CVM_JVMPI *//* Purpose: Notifies the next thread waiting on this monitor. *//* Returns: If the current_ee passed in is not the owner of the monitor, CVM_FALSE will be returned. Else, returns CVM_TRUE. *//* inline CVMBool CVMprofiledMonitorNotify(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorNotify(self, currentEE) \ CVMsysMonitorNotify((currentEE), (&(self)->_super))/* Purpose: Notifies all threads waiting on this monitor. *//* Returns: If the current_ee passed in is not the owner of the monitor, CVM_FALSE will be returned. Else, returns CVM_TRUE. *//* inline CVMBool CVMprofiledMonitorNotifyAll(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorNotifyAll(self, currentEE) \ CVMsysMonitorNotifyAll((currentEE), (&(self)->_super))/* Purpose: Wait for the specified time period (in milliseconds). If the period is 0, then wait forever. *//* Returns: CVM_WAIT_NOT_OWNER if current_ee is not the owner of the monitor, CVM_WAIT_OK if the thread was woken up by a timeout, and CVM_WAIT_INTERRUPTED is the thread was woken up by a notify. *//* NOTE: Thread must be in a GC safe state before calling this. */#if defined(CVM_JVMPI) || defined(CVM_JVMTI)extern CVMWaitStatusCVMprofiledMonitorWait(CVMProfiledMonitor *self, CVMExecEnv *currentEE, CVMInt64 millis);#else /* !CVM_JVMPI *//* inline CVMWaitStatus CVMprofiledMonitorWait(CVMProfiledMonitor *self, CVMExecEnv *currentEE, CVMInt64 millis); */#define CVMprofiledMonitorWait(self, currentEE, millis) \ CVMsysMonitorWait((currentEE), (&(self)->_super), (millis))#endif /* CVM_JVMPI *//* Purpose: Gets the current owner ee of this monitor. *//* inline CVMExecEnv *CVMprofiledMonitorGetOwner(CVMProfiledMonitor *self); */#define CVMprofiledMonitorGetOwner(self) \ CVMsysMonitorOwner(&(self)->_super)/* Purpose: Gets the current lock count of this monitor. *//* inline CVMUint32 CVMprofiledMonitorGetCount(CVMProfiledMonitor *self); */#define CVMprofiledMonitorGetCount(self) \ CVMsysMonitorCount(&(self)->_super)#ifdef CVM_THREAD_BOOST/* Purpose: Acquire the underlying mutex of this monitor, ignoring owner and entry count. *//* inline CVMUint32 CVMprofiledMonitorAcquireMutex(CVMExecEnv *currentEE, CVMProfiledMonitor *pmon); */#define CVMprofiledMonitorAcquireMutex(currentEE, pmon) \ CVMsysMonitorAcquireMutex((currentEE), (&(pmon)->_super))#else/* Purpose: Sets the current owner threadID in the underlying mutex of this monitor. *//* inline CVMUint32 CVMprofiledMonitorSetMutexOwner(CVMProfiledMonitor *self, CVMExecEnv *currentEE, CVMExecEnv *ownerEE); */#define CVMprofiledMonitorSetMutexOwner(self, currentEE, ownerEE) \ CVMsysMonitorSetMutexOwner((currentEE), (&(self)->_super), (ownerEE))#endif/* Purpose: Tries to enter the monitor. *//* inline CVMBool CVMprofiledMonitorTryEnter(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorTryEnter(self, currentEE) \ CVMsysMonitorTryEnter((currentEE), (&(self)->_super))/* Purpose: Enters monitor while thread is in a GC unsafe state. */#if defined(CVM_JVMPI) || defined(CVM_JVMTI)extern voidCVMprofiledMonitorEnterUnsafe(CVMProfiledMonitor *self, CVMExecEnv *currentEE, CVMBool doPost);#ifdef CVM_THREAD_BOOSTextern voidCVMprofiledMonitorPreContendedEnterUnsafe(CVMProfiledMonitor *self, CVMExecEnv *currentEE);extern voidCVMprofiledMonitorContendedEnterUnsafe(CVMProfiledMonitor *self, CVMExecEnv *currentEE);#endif#else /* !CVM_JVMPI *//* inline void CVMprofiledMonitorEnterUnsafe(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorEnterUnsafe(self, currentEE, doPost) \ CVMsysMonitorEnterUnsafe((currentEE), (&(self)->_super))#ifdef CVM_THREAD_BOOST#define CVMprofiledMonitorPreContendedEnterUnsafe(self, currentEE)#define CVMprofiledMonitorContendedEnterUnsafe(self, currentEE) \ CVMsysMonitorEnterUnsafe((currentEE), (&(self)->_super))#endif#endif /* CVM_JVMPI *//* Purpose: Enters monitor while thread is in a GC safe state. */#if defined(CVM_JVMPI) || defined(CVM_JVMTI)extern voidCVMprofiledMonitorEnterSafe(CVMProfiledMonitor *self, CVMExecEnv *currentEE, CVMBool doPost);#else /* !CVM_JVMPI *//* inline void CVMprofiledMonitorEnterSafe(CVMProfiledMonitor *self, CVMExecEnv *currentEE); */#define CVMprofiledMonitorEnterSafe(self, currentEE, doPost) \ CVMsysMonitorEnterSafe((currentEE), (&(self)->_super))#endif /* CVM_JVMPI *//*===========================================================================*//* * GC support */extern voidCVMdeleteUnreferencedMonitors(CVMExecEnv *ee, CVMRefLivenessQueryFunc isLive, void* isLiveData, CVMRefCallbackFunc transitiveScanner, void* transitiveScannerData);extern voidCVMscanMonitors(CVMExecEnv *ee, CVMRefCallbackFunc refCallback, void* data);extern CVMBoolCVMeeSyncInit(CVMExecEnv *ee);extern voidCVMeeSyncDestroy(CVMExecEnv *ee);extern CVMBoolCVMeeSyncInitGlobal(CVMExecEnv *ee, CVMGlobalState *gs);extern voidCVMeeSyncDestroyGlobal(CVMExecEnv *ee, CVMGlobalState *gs);/* * Support for debug stubs. */#if defined(CVM_PORTING_DEBUG_STUBS) && !defined(CVM_PORTING_DEBUG_IMPL)#undef CVMmutexInit#define CVMmutexInit(m) \ CVMmutexInitStub((m))CVMBool CVMmutexInitStub(CVMMutex* m);#undef CVMmutexDestroy#define CVMmutexDestroy(m) \ CVMmutexDestroyStub((m))CVMBool CVMmutexDestroyStub(CVMMutex* m);#undef CVMcondvarInit#define CVMcondvarInit(c,m) \ CVMcondvarInitStub((c),(m))CVMBool CVMcondvarInitStub(CVMCondVar* c, CVMMutex* m);#undef CVMcondvarDestroy#define CVMcondvarDestroy(c) \ CVMcondvarDestroyStub((c))CVMBool CVMcondvarDestroyStub(CVMCondVar* c);#endif#endif /* !_ASM */#endif /* _INCLUDED_SYNC_H */
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?