Changeset 19057
- Timestamp:
- Aug 13, 2008, 5:22:13 PM (18 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 3 edited
-
imageops/psImageConvolve.c (modified) (2 diffs)
-
sys/psThread.c (modified) (3 diffs)
-
sys/psThread.h (modified) (4 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageConvolve.c
r19015 r19057 7 7 /// @author Eugene Magnier, IfA 8 8 /// 9 /// @version $Revision: 1.7 3$ $Name: not supported by cvs2svn $10 /// @date $Date: 2008-08-1 2 03:08:41$9 /// @version $Revision: 1.74 $ $Name: not supported by cvs2svn $ 10 /// @date $Date: 2008-08-14 03:22:13 $ 11 11 /// 12 12 /// Copyright 2004-2007 Institute for Astronomy, University of Hawaii … … 1071 1071 } 1072 1072 } else if (!set && threaded) { 1073 psThreadTask Delete("PSLIB_IMAGE_CONVOLVE_MASK");1073 psThreadTaskRemove("PSLIB_IMAGE_CONVOLVE_MASK"); 1074 1074 } 1075 1075 -
trunk/psLib/src/sys/psThread.c
r19016 r19057 26 26 static psArray *pool = NULL; // array of defined threads 27 27 static psHash *tasks = NULL; // List of defined tasks 28 static psArray *tsd = NULL; // Thread-specific data 28 29 29 30 … … 165 166 } 166 167 167 bool psThreadTask Delete(const char *type)168 bool psThreadTaskRemove(const char *type) 168 169 { 169 170 PS_ASSERT_STRING_NON_EMPTY(type, false); … … 316 317 tasks = NULL; 317 318 319 psFree(tsd); 320 tsd = NULL; 321 318 322 return true; 319 323 } 320 324 325 326 #if 0 327 // This doesn't work like I thought it would: pthread_self can return anything. 328 bool psThreadDataAdd(const char *name, psPtr ptr) 329 { 330 PS_ASSERT_STRING_NON_EMPTY(name, false); 331 PS_ASSERT_PTR_NON_NULL(ptr, false); 332 333 pthread_key_t *key = psAlloc(sizeof(pthread_key_t)); // Key for data 334 pthread_key_create(key, psFree); 335 336 if (!tsd) { 337 tsd = psArrayAlloc(numThreads); 338 } 339 340 psHashAdd( 341 342 pthread_t tid = pthread_self(); // Thread identifier 343 int numThreads = psThreadPoolSize();// Number of threads 344 psAssert(tid < numThreads, "Thread identifier (%d) exceeds number of threads (%d)", (int)tid, numThreads); 345 346 if (!tsd) { 347 tsd = psArrayAlloc(numThreads); 348 } 349 350 psHash *hash = tsd->data[tid]; // Thread-specific hash of data 351 return psHashAdd(hash, name, ptr); 352 } 353 354 void *psThreadDataLookup(const char *name) 355 { 356 PS_ASSERT_STRING_NON_EMPTY(name, NULL); 357 358 if (!tsd) { 359 return NULL; 360 } 361 362 pthread_t tid = pthread_self(); // Thread identifier 363 int numThreads = psThreadPoolSize();// Number of threads 364 psAssert(tid < numThreads, "Thread identifier (%d) exceeds number of threads (%d)", (int)tid, numThreads); 365 366 psHash *hash = tsd->data[tid]; // Thread-specific hash of data 367 return psHashLookup(hash, name); 368 } 369 370 bool psThreadDataRemove(const char *name) 371 { 372 PS_ASSERT_STRING_NON_EMPTY(name, false); 373 374 if (!tsd) { 375 return false; 376 } 377 378 pthread_t tid = pthread_self(); // Thread identifier 379 int numThreads = psThreadPoolSize();// Number of threads 380 psAssert(tid < numThreads, "Thread identifier (%d) exceeds number of threads (%d)", (int)tid, numThreads); 381 382 psHash *hash = tsd->data[tid]; // Thread-specific hash of data 383 return psHashRemove(hash, name); 384 } 385 #endif -
trunk/psLib/src/sys/psThread.h
r19022 r19057 4 4 * 5 5 * @author EAM, IFA 6 * @version $Revision: 1. 4$ $Name: not supported by cvs2svn $7 * @date $Date: 2008-08-1 2 03:28:37$6 * @version $Revision: 1.5 $ $Name: not supported by cvs2svn $ 7 * @date $Date: 2008-08-14 03:22:13 $ 8 8 * 9 9 * Copyright 2004-2005 Insitute for Astronomy, University of Hawaii … … 12 12 #ifndef PS_THREAD_H 13 13 #define PS_THREAD_H 14 15 #include <pthread.h> 16 #include "psString.h" 17 #include "psArray.h" 14 18 15 19 /// @addtogroup SysUtils System Utilities … … 87 91 88 92 /// Remove a task from the list 89 bool psThreadTask Delete(const char *type // Task type to remove93 bool psThreadTaskRemove(const char *type // Task type to remove 90 94 ); 91 95 … … 111 115 bool psThreadPoolFinalize(void); 112 116 117 118 /// Add thread-specific data 119 /// 120 /// The provided pointer is added to a thread-specific hash under the provided name. 121 bool psThreadDataAdd(const char *name, // Name of data 122 psPtr ptr // Data to add 123 ); 124 125 /// Lookup thread-specific data 126 /// 127 /// The thread-specific hash is interrogated using the provided name. 128 void *psThreadDataLookup(const char *name // Name of data 129 ); 130 131 /// Remove thread-specific data 132 /// 133 /// The thread-specific hash has the data associated with the provided name deleted. 134 bool psThreadDataRemove(const char *name // Name of data 135 ); 136 137 113 138 /// @} 114 139 #endif /* PS_THREAD_H */
Note:
See TracChangeset
for help on using the changeset viewer.
