thread.c (647f063d) | thread.c (509a48ff) |
---|---|
1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 68 unchanged lines hidden (view full) --- 77{ 78 osl_TThreadImpl* pThreadImpl; 79 80 /* alloc mem. for our internal data structure */ 81 pThreadImpl= malloc(sizeof(osl_TThreadImpl)); 82 83 OSL_ASSERT(pThreadImpl); 84 | 1/************************************************************** 2 * 3 * Licensed to the Apache Software Foundation (ASF) under one 4 * or more contributor license agreements. See the NOTICE file 5 * distributed with this work for additional information 6 * regarding copyright ownership. The ASF licenses this file 7 * to you under the Apache License, Version 2.0 (the 8 * "License"); you may not use this file except in compliance --- 68 unchanged lines hidden (view full) --- 77{ 78 osl_TThreadImpl* pThreadImpl; 79 80 /* alloc mem. for our internal data structure */ 81 pThreadImpl= malloc(sizeof(osl_TThreadImpl)); 82 83 OSL_ASSERT(pThreadImpl); 84 |
85 if ( pThreadImpl == 0 ) | 85 if ( pThreadImpl == NULL ) |
86 { 87 return 0; 88 } 89 90 pThreadImpl->m_WorkerFunction= pWorker; 91 pThreadImpl->m_pData= pThreadData; 92 pThreadImpl->m_nTerminationRequested= 0; 93 --- 151 unchanged lines hidden (view full) --- 245oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread) 246{ 247 int winPriority; 248 oslThreadPriority Priority; 249 250 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 251 252 /* invalid arguments ?*/ | 86 { 87 return 0; 88 } 89 90 pThreadImpl->m_WorkerFunction= pWorker; 91 pThreadImpl->m_pData= pThreadData; 92 pThreadImpl->m_nTerminationRequested= 0; 93 --- 151 unchanged lines hidden (view full) --- 245oslThreadPriority SAL_CALL osl_getThreadPriority(const oslThread Thread) 246{ 247 int winPriority; 248 oslThreadPriority Priority; 249 250 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 251 252 /* invalid arguments ?*/ |
253 if(pThreadImpl==0 || pThreadImpl->m_hThread==0) | 253 if(pThreadImpl==NULL || pThreadImpl->m_hThread==0) |
254 { 255 return osl_Thread_PriorityUnknown; 256 } 257 258 winPriority= 259 GetThreadPriority(pThreadImpl->m_hThread); 260 261 --- 40 unchanged lines hidden (view full) --- 302/*****************************************************************************/ 303/* osl_isThreadRunning */ 304/*****************************************************************************/ 305sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread) 306{ 307 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 308 309 /* invalid arguments ?*/ | 254 { 255 return osl_Thread_PriorityUnknown; 256 } 257 258 winPriority= 259 GetThreadPriority(pThreadImpl->m_hThread); 260 261 --- 40 unchanged lines hidden (view full) --- 302/*****************************************************************************/ 303/* osl_isThreadRunning */ 304/*****************************************************************************/ 305sal_Bool SAL_CALL osl_isThreadRunning(const oslThread Thread) 306{ 307 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 308 309 /* invalid arguments ?*/ |
310 if(pThreadImpl==0 || pThreadImpl->m_hThread==0) | 310 if(pThreadImpl==NULL || pThreadImpl->m_hThread==0) |
311 { 312 return sal_False; 313 } 314 315 return (sal_Bool)(WaitForSingleObject(pThreadImpl->m_hThread, 0) != WAIT_OBJECT_0); 316} 317 318/*****************************************************************************/ 319/* osl_joinWithThread */ 320/*****************************************************************************/ 321void SAL_CALL osl_joinWithThread(oslThread Thread) 322{ 323 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 324 325 /* invalid arguments?*/ | 311 { 312 return sal_False; 313 } 314 315 return (sal_Bool)(WaitForSingleObject(pThreadImpl->m_hThread, 0) != WAIT_OBJECT_0); 316} 317 318/*****************************************************************************/ 319/* osl_joinWithThread */ 320/*****************************************************************************/ 321void SAL_CALL osl_joinWithThread(oslThread Thread) 322{ 323 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 324 325 /* invalid arguments?*/ |
326 if(pThreadImpl==0 || pThreadImpl->m_hThread==0) | 326 if(pThreadImpl==NULL || pThreadImpl->m_hThread==0) |
327 { 328 /* assume thread is not running */ 329 return; 330 } 331 332 WaitForSingleObject(pThreadImpl->m_hThread, INFINITE); 333} 334 --- 13 unchanged lines hidden (view full) --- 348/*****************************************************************************/ 349/* osl_terminateThread */ 350/*****************************************************************************/ 351void SAL_CALL osl_terminateThread(oslThread Thread) 352{ 353 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 354 355 /* invalid arguments?*/ | 327 { 328 /* assume thread is not running */ 329 return; 330 } 331 332 WaitForSingleObject(pThreadImpl->m_hThread, INFINITE); 333} 334 --- 13 unchanged lines hidden (view full) --- 348/*****************************************************************************/ 349/* osl_terminateThread */ 350/*****************************************************************************/ 351void SAL_CALL osl_terminateThread(oslThread Thread) 352{ 353 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 354 355 /* invalid arguments?*/ |
356 if (pThreadImpl==0 || pThreadImpl->m_hThread==0) | 356 if (pThreadImpl==NULL || pThreadImpl->m_hThread==0) |
357 { 358 /* assume thread is not running */ 359 return; 360 } 361 362 osl_incrementInterlockedCount(&(pThreadImpl->m_nTerminationRequested)); 363} 364 365 366/*****************************************************************************/ 367/* osl_scheduleThread */ 368/*****************************************************************************/ 369sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread) 370{ 371 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 372 373 osl_yieldThread(); 374 375 /* invalid arguments?*/ | 357 { 358 /* assume thread is not running */ 359 return; 360 } 361 362 osl_incrementInterlockedCount(&(pThreadImpl->m_nTerminationRequested)); 363} 364 365 366/*****************************************************************************/ 367/* osl_scheduleThread */ 368/*****************************************************************************/ 369sal_Bool SAL_CALL osl_scheduleThread(oslThread Thread) 370{ 371 osl_TThreadImpl* pThreadImpl= (osl_TThreadImpl*)Thread; 372 373 osl_yieldThread(); 374 375 /* invalid arguments?*/ |
376 if (pThreadImpl==0 || pThreadImpl->m_hThread==0) | 376 if (pThreadImpl==NULL || pThreadImpl->m_hThread==0) |
377 { 378 /* assume thread is not running */ 379 return sal_False; 380 } 381 382 return (sal_Bool)(0 == pThreadImpl->m_nTerminationRequested); 383} 384 --- 42 unchanged lines hidden (view full) --- 427 428static void AddKeyToList( PTLS pTls ) 429{ 430 if ( pTls ) 431 { 432 EnterCriticalSection( &g_ThreadKeyListCS ); 433 434 pTls->pNext = g_pThreadKeyList; | 377 { 378 /* assume thread is not running */ 379 return sal_False; 380 } 381 382 return (sal_Bool)(0 == pThreadImpl->m_nTerminationRequested); 383} 384 --- 42 unchanged lines hidden (view full) --- 427 428static void AddKeyToList( PTLS pTls ) 429{ 430 if ( pTls ) 431 { 432 EnterCriticalSection( &g_ThreadKeyListCS ); 433 434 pTls->pNext = g_pThreadKeyList; |
435 pTls->pPrev = 0; | 435 pTls->pPrev = NULL; |
436 437 if ( g_pThreadKeyList ) 438 g_pThreadKeyList->pPrev = pTls; 439 440 g_pThreadKeyList = pTls; 441 442 LeaveCriticalSection( &g_ThreadKeyListCS ); 443 } --- 48 unchanged lines hidden (view full) --- 492 PTLS pTls = rtl_allocateMemory( sizeof(TLS) ); 493 494 if ( pTls ) 495 { 496 pTls->pfnCallback = pCallback; 497 if ( (DWORD)-1 == (pTls->dwIndex = TlsAlloc()) ) 498 { 499 rtl_freeMemory( pTls ); | 436 437 if ( g_pThreadKeyList ) 438 g_pThreadKeyList->pPrev = pTls; 439 440 g_pThreadKeyList = pTls; 441 442 LeaveCriticalSection( &g_ThreadKeyListCS ); 443 } --- 48 unchanged lines hidden (view full) --- 492 PTLS pTls = rtl_allocateMemory( sizeof(TLS) ); 493 494 if ( pTls ) 495 { 496 pTls->pfnCallback = pCallback; 497 if ( (DWORD)-1 == (pTls->dwIndex = TlsAlloc()) ) 498 { 499 rtl_freeMemory( pTls ); |
500 pTls = 0; | 500 pTls = NULL; |
501 } 502 else 503 AddKeyToList( pTls ); 504 } 505 506 return ((oslThreadKey)pTls); 507} 508 --- 106 unchanged lines hidden --- | 501 } 502 else 503 AddKeyToList( pTls ); 504 } 505 506 return ((oslThreadKey)pTls); 507} 508 --- 106 unchanged lines hidden --- |