Changeset 8839 for trunk/src/kernel32/overlappedio.cpp
- Timestamp:
- Jul 5, 2002, 7:58:26 PM (23 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/kernel32/overlappedio.cpp
r8647 r8839 1 /* $Id: overlappedio.cpp,v 1.1 7 2002-06-11 16:36:06 sandervl Exp $ */1 /* $Id: overlappedio.cpp,v 1.18 2002-07-05 17:58:26 sandervl Exp $ */ 2 2 3 3 /* … … 29 29 LPOVERLAPPED_HANDLER lpPollHandler, 30 30 BOOL fFullDuplex) : 31 hThreadRead(0), hThreadWrite(0), hThreadPoll(0) 31 hThreadRead(0), hThreadWrite(0), hThreadPoll(0), refCount(0) 32 32 { 33 33 OverlappedIOError errcode = OutOfMemory; … … 75 75 threadparam->lpOverlappedObj = this; 76 76 hThreadRead = ::CreateThread(NULL, 32*1024, OverlappedIOThread, (LPVOID)threadparam, 0, &dwThreadId); 77 if(hThreadRead) {//thread uses this object; keep reference count to avoid premature destruction 78 AddRef(); 79 } 77 80 78 81 if(lpWriteHandler && fFullDuplex) { … … 84 87 threadparam->lpOverlappedObj = this; 85 88 hThreadWrite = ::CreateThread(NULL, 32*1024, OverlappedIOThread, (LPVOID)threadparam, 0, &dwThreadId); 89 if(hThreadWrite) {//thread uses this object; keep reference count to avoid premature destruction 90 AddRef(); 91 } 86 92 } 87 93 … … 95 101 hThreadPoll = ::CreateThread(NULL, 32*1024, OverlappedIOThread, (LPVOID)threadparam, 0, &dwThreadId); 96 102 SetThreadPriority(hThreadPoll, THREAD_PRIORITY_TIME_CRITICAL); 103 if(hThreadPoll) {//thread uses this object; keep reference count to avoid premature destruction 104 AddRef(); 105 } 97 106 } 98 107 … … 146 155 147 156 DeleteCriticalSection(&critsect); 157 } 158 //****************************************************************************** 159 //****************************************************************************** 160 DWORD OverlappedIOHandler::AddRef() 161 { 162 return InterlockedIncrement(&refCount); 163 } 164 //****************************************************************************** 165 //****************************************************************************** 166 DWORD OverlappedIOHandler::Release(BOOL fSignalExit) 167 { 168 if(fSignalExit) { 169 ::SetEvent(hEventExit); 170 } 171 if(InterlockedDecrement(&refCount) == 0) { 172 dprintf(("OverlappedIOHandler::Release -> delete now")); 173 delete this; 174 return 0; 175 } 176 return refCount; 148 177 } 149 178 //****************************************************************************** … … 314 343 } //while(TRUE) 315 344 } 345 Release(); //decrease reference count 316 346 return 0; 317 347 }
Note:
See TracChangeset
for help on using the changeset viewer.