MCPcopy Create free account
hub / github.com/OpenKinect/libfreenect2 / thread

Method thread

src/tinythread/tinythread.cpp:179–208  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

177}
178
179thread::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
210thread::~thread()
211{

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected