📄 liblock.c
字号:
/* thread-locking library, RTK addition by luz@synthesis.ch */#include "syncml_tk_prefix_file.h" // %%% luz: needed for precompiled headers in eVC++#define _IMPLEMENTS_LOCK_GLOBALS#include "liblock.h"#undef _IMPLEMENTS_LOCK_GLOBALS#ifdef __DEBUG_LOCKSstatic short gLockNest;void _ToolKitLockInit(const char *msg){ gLockNest=0; InitializeCriticalSection(&gSmlLock); DEBUGPRINTF(("Toolkitlock initialized from '%s'",msg))} // _ToolKitLockInit void _ToolKitLockFree(const char *msg) { DeleteCriticalSection(&gSmlLock); DEBUGPRINTF(("Toolkitlock freed from '%s'",msg));} // _ToolKitLockFreevoid _LockToolKit(const char *msg){ short sec=0; int k; if (!TryEnterCriticalSection(&gSmlLock)) { // could not enter for (k=0; k<10; k++) { Sleep(100); // wait 0.1 sec if (TryEnterCriticalSection(&gSmlLock)) goto entered; } // could not enter after 1 sec DEBUGPRINTF(("Toolkitlock not free after 1 sec trying...")) do { Sleep(30000); // wait 30 secs sec+=30; if (TryEnterCriticalSection(&gSmlLock)) goto entered; DEBUGPRINTF(("Toolkitlock not free after %d sec trying...",sec)) } while (1); } entered: #if __DEBUG_LOCKS>1 DEBUGPRINTF(("Toolkitlock entered from '%s'",msg)) #endif ;} // _LockToolKitvoid _ReleaseToolKit(const char *msg){ LeaveCriticalSection(&gSmlLock); #if __DEBUG_LOCKS>1 DEBUGPRINTF(("Toolkitlock released from '%s'",msg)) #endif} // _ReleaseToolKit #endif/* eof */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -