Changeset 9235 for trunk/src/kernel32/HandleManager.cpp
- Timestamp:
- Sep 14, 2002, 3:49:39 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/HandleManager.cpp
r8952 r9235 1 /* $Id: HandleManager.cpp,v 1.9 0 2002-08-01 16:02:40sandervl Exp $ */1 /* $Id: HandleManager.cpp,v 1.91 2002-09-14 13:49:39 sandervl Exp $ */ 2 2 3 3 /* … … 1982 1982 } 1983 1983 1984 //If the timeout is less than 20 milliseconds (and not zero), then we are likely to 1985 //return too late if the thread priority isn't time critical (time slices 1986 //of 32 ms) 1987 //To avoid this problem, we temporarily switch to time critical priority. 1988 HANDLE hThread = GetCurrentThread(); 1989 DWORD dwThreadPriority = GetThreadPriority(hThread); 1990 1991 if(dwTimeout && dwTimeout < 20 && dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) { 1992 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 1993 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 1994 //round to 8 ms units to get more precise timeouts 1995 if(dwTimeout > 8) 1996 dwTimeout = (dwTimeout/8)*8; 1997 } 1998 else dwThreadPriority = -1; 1999 1984 2000 pHMHandle = &TabWin32Handles[iIndex]; /* call device handler */ 1985 2001 dwResult = pHMHandle->pDeviceHandler->WaitForSingleObject(&pHMHandle->hmHandleData, 1986 2002 dwTimeout); 1987 2003 2004 //Restore thread priority if we previously changed it 2005 if(dwThreadPriority != -1) { 2006 SetThreadPriority(hThread, dwThreadPriority); 2007 } 1988 2008 return (dwResult); /* deliver return code */ 1989 2009 } … … 2982 3002 } 2983 3003 3004 //If the timeout is less than 20 milliseconds (and not zero), then we are likely to 3005 //return too late if the thread priority isn't time critical (time slices 3006 //of 32 ms) 3007 //To avoid this problem, we temporarily switch to time critical priority. 3008 HANDLE hThread = GetCurrentThread(); 3009 DWORD dwThreadPriority = GetThreadPriority(hThread); 3010 3011 if(dwTimeout && dwTimeout < 20 && dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) { 3012 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 3013 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 3014 //round to 8 ms units to get more precise timeouts 3015 if(dwTimeout > 8) 3016 dwTimeout = (dwTimeout/8)*8; 3017 } 3018 else dwThreadPriority = -1; 3019 2984 3020 // OK, now forward to Open32. 2985 3021 // @@@PH: Note this will fail on handles that do NOT belong to Open32 … … 2990 3026 dwTimeout); 2991 3027 3028 //Restore old thread priority if we changed it before 3029 if(dwThreadPriority != -1) { 3030 SetThreadPriority(hThread, dwThreadPriority); 3031 } 3032 2992 3033 return (rc); // OK, done 2993 3034 #endif … … 3112 3153 } 3113 3154 3155 //If the timeout is less than 20 milliseconds (and not zero), then we are likely to 3156 //return too late if the thread priority isn't time critical (time slices 3157 //of 32 ms) 3158 //To avoid this problem, we temporarily switch to time critical priority. 3159 HANDLE hThread = GetCurrentThread(); 3160 DWORD dwThreadPriority = GetThreadPriority(hThread); 3161 3162 if(dwTimeout && dwTimeout < 20 && dwThreadPriority != THREAD_PRIORITY_TIME_CRITICAL) { 3163 dprintf(("Temporarily change priority to THREAD_PRIORITY_TIME_CRITICAL for better timing")); 3164 SetThreadPriority(hThread, THREAD_PRIORITY_TIME_CRITICAL); 3165 //round to 8 ms units to get more precise timeouts 3166 if(dwTimeout > 8) 3167 dwTimeout = (dwTimeout/8)*8; 3168 } 3169 else dwThreadPriority = -1; 3170 3114 3171 // OK, now forward to Open32. 3115 3172 // @@@PH: Note this will fail on handles that do NOT belong to Open32 … … 3119 3176 fWaitAll, dwTimeout, 3120 3177 dwWakeMask); 3178 3179 //Restore old thread priority if we changed it before 3180 if(dwThreadPriority != -1) { 3181 SetThreadPriority(hThread, dwThreadPriority); 3182 } 3121 3183 3122 3184 dprintf2(("MsgWaitForMultipleObjects returned %d", rc));
Note:
See TracChangeset
for help on using the changeset viewer.