| 177 | } |
| 178 | |
| 179 | thread::thread(void (*aFunction)(void *), void * aArg) |
| 180 | { |
| 181 | // Serialize access to this thread structure |
| 182 | lock_guard<mutex> guard(mDataMutex); |
| 183 | |
| 184 | // Fill out the thread startup information (passed to the thread wrapper, |
| 185 | // which will eventually free it) |
| 186 | _thread_start_info * ti = new _thread_start_info; |
| 187 | ti->mFunction = aFunction; |
| 188 | ti->mArg = aArg; |
| 189 | ti->mThread = this; |
| 190 | |
| 191 | // The thread is now alive |
| 192 | mNotAThread = false; |
| 193 | |
| 194 | // Create the thread |
| 195 | #if defined(_TTHREAD_WIN32_) |
| 196 | mHandle = (HANDLE) _beginthreadex(0, 0, wrapper_function, (void *) ti, 0, &mWin32ThreadID); |
| 197 | #elif defined(_TTHREAD_POSIX_) |
| 198 | if(pthread_create(&mHandle, NULL, wrapper_function, (void *) ti) != 0) |
| 199 | mHandle = 0; |
| 200 | #endif |
| 201 | |
| 202 | // Did we fail to create the thread? |
| 203 | if(!mHandle) |
| 204 | { |
| 205 | mNotAThread = true; |
| 206 | delete ti; |
| 207 | } |
| 208 | } |
| 209 | |
| 210 | thread::~thread() |
| 211 | { |
nothing calls this directly
no outgoing calls
no test coverage detected