Changeset 35:f8a5b321d0c3 in xplcommon for src/xplcommon/win32/Thread.h
- Timestamp:
- 01/03/13 06:57:15 (11 years ago)
- Branch:
- default
- Phase:
- public
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/xplcommon/win32/Thread.h
r20 r35 58 58 59 59 /** 60 * Indicate if the thread is detached. 61 */ 62 bool detached; 63 64 /** 60 65 * The thread handle. 61 66 */ … … 63 68 64 69 public: 70 /** 71 * Construct the thread object. 72 */ 73 Thread(bool detached = false); 74 65 75 /** 66 76 * Virtual destructor. … … 84 94 */ 85 95 void join(); 96 97 void release(); 86 98 }; 87 99 … … 97 109 //------------------------------------------------------------------------------ 98 110 111 inline Thread::Thread(bool detached) : 112 detached(detached), 113 handle(0) 114 { 115 } 116 117 //------------------------------------------------------------------------------ 118 99 119 inline Thread::~Thread() 100 120 { … … 106 126 { 107 127 handle = CreateThread(0, 0, &threadFn, this, 0, 0); 108 return handle!=0; 128 bool isOK = handle!=0; 129 if (detached && handle!=0) { 130 CloseHandle(handle); 131 handle = 0; 132 } 133 return isOK; 109 134 } 110 135 … … 113 138 inline void Thread::join() 114 139 { 115 WaitForSingleObject(handle, INFINITE); 140 if (handle!=0) { 141 WaitForSingleObject(handle, INFINITE); 142 CloseHandle(handle); 143 } 116 144 } 117 145
Note:
See TracChangeset
for help on using the changeset viewer.