Changeset 28402
- Timestamp:
- Jun 18, 2010, 10:48:42 AM (16 years ago)
- Location:
- trunk/psLib/src/sys
- Files:
-
- 2 edited
-
psThread.c (modified) (4 diffs)
-
psThread.h (modified) (1 diff)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/sys/psThread.c
r28400 r28402 38 38 static psList *pending = NULL; // queue of pending jobs 39 39 static psList *done = NULL; // queue of done jobs 40 static pthread_t *threads = NULL; // array of the POSIX thread handles 40 41 static psArray *pool = NULL; // array of defined threads 41 42 static psHash *tasks = NULL; // List of defined tasks 42 43 static psArray *tsd = NULL; // Thread-specific data 43 44 44 45 45 /***** basic thread functions *****/ … … 265 265 bool psThreadPoolInit(int nThreads) 266 266 { 267 if (pool ) {267 if (pool || threads) { 268 268 psAbort("psThreadsInit already called"); 269 269 } … … 276 276 277 277 pool = psArrayAlloc(nThreads); 278 threads = psAlloc(nThreads * sizeof(pthread_t)); 278 279 for (int i = 0; i < nThreads; i++) { 279 psThread *thread = p sThreadAlloc(); // Thread for pool280 i nt success = pthread_create(&thread->pt, NULL, psThreadLauncher, thread);281 psAssert(!success, "Unable to startthread");282 pool->data[i] = thread;280 psThread *thread = pool->data[i] = psThreadAlloc(); // Thread for pool 281 if (!pthread_create(&threads[i], NULL, psThreadLauncher, thread)) { 282 psAbort("Unable to create thread"); 283 } 283 284 } 284 285 return true; … … 376 377 pool = NULL; 377 378 379 psFree(threads); 380 threads = NULL; 381 378 382 psFree(tasks); 379 383 tasks = NULL; -
trunk/psLib/src/sys/psThread.h
r19297 r28402 41 41 bool busy; // Is the thread busy? 42 42 bool fault; // Has the thread faulted? 43 pthread_t pt; // The thread itself44 43 } psThread; 45 44
Note:
See TracChangeset
for help on using the changeset viewer.
