Changeset 6419 for trunk/psLib/src/types
- Timestamp:
- Feb 9, 2006, 4:44:46 PM (20 years ago)
- Location:
- trunk/psLib/src/types
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/types/psList.c
r5511 r6419 6 6 * @author Robert Daniel DeSonia, MHPCC 7 7 * 8 * @version $Revision: 1.4 5$ $Name: not supported by cvs2svn $9 * @date $Date: 200 5-11-14 22:18:34$8 * @version $Revision: 1.46 $ $Name: not supported by cvs2svn $ 9 * @date $Date: 2006-02-10 02:44:46 $ 10 10 * 11 11 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 33 33 static psBool listIteratorRemove(psListIterator* iterator); 34 34 35 //private boolean for enabling/disabling thread safety. Default = enabled. 36 static bool safeThreads = true; 37 35 38 static void listFree(psList* list) 36 39 { … … 39 42 } 40 43 41 pthread_mutex_lock(&list->p_lock); 44 if (safeThreads) { 45 pthread_mutex_lock(&list->p_lock); 46 // pthread_mutex_lock(&p_lock); 47 } 42 48 43 49 // remove the associated iterators -- any references are invalid once psList is freed. … … 64 70 } 65 71 66 pthread_mutex_unlock(&list->p_lock); 67 68 pthread_mutex_destroy(&list->p_lock); 69 72 if (safeThreads) { 73 pthread_mutex_unlock(&list->p_lock); 74 pthread_mutex_destroy(&list->p_lock); 75 // pthread_mutex_unlock(&p_lock); 76 // pthread_mutex_destroy(&p_lock); 77 } else { 78 safeThreads = true; 79 } 70 80 } 71 81 … … 100 110 int index = iterator->index; 101 111 102 pthread_mutex_lock(&list->p_lock); 103 112 if (safeThreads) { 113 pthread_mutex_lock(&list->p_lock); 114 // pthread_mutex_lock(&p_lock); 115 } 104 116 if (elem == list->head) { // head of list? 105 117 list->head = elem->next; … … 126 138 list->n--; 127 139 128 pthread_mutex_unlock(&list->p_lock) 129 ; 140 if (safeThreads) { 141 pthread_mutex_unlock(&list->p_lock); 142 // pthread_mutex_unlock(&p_lock); 143 } 130 144 131 145 // OK, delete orphaned list element and its data … … 150 164 psListIteratorAlloc(list,PS_LIST_HEAD,true); 151 165 152 pthread_mutex_init(&(list->p_lock), NULL); 166 if (safeThreads) { 167 pthread_mutex_init(&(list->p_lock), NULL); 168 // pthread_mutex_init(&p_lock, NULL); 169 } 153 170 154 171 if (data != NULL) { … … 164 181 } 165 182 166 183 bool p_psListThreadSafety(bool safe) 184 { 185 bool out = safeThreads; 186 safeThreads = safe; 187 return out; 188 } 167 189 168 190 psListIterator* psListIteratorAlloc(psList* list, long location, bool mutable) … … 326 348 psListElem* elem = psAlloc(sizeof(psListElem)); 327 349 328 pthread_mutex_lock(&list->p_lock); 350 if (safeThreads) { 351 pthread_mutex_lock(&list->p_lock); 352 // pthread_mutex_lock(&p_lock); 353 } 329 354 330 355 // set the new list element's attributes … … 362 387 } 363 388 364 pthread_mutex_unlock(&list->p_lock); 389 if (safeThreads) { 390 pthread_mutex_unlock(&list->p_lock); 391 // pthread_mutex_unlock(&p_lock); 392 } 365 393 366 394 return true; … … 399 427 psListElem* elem = psAlloc(sizeof(psListElem)); 400 428 401 pthread_mutex_lock(&list->p_lock); 429 if (safeThreads) { 430 pthread_mutex_lock(&list->p_lock); 431 // pthread_mutex_lock(&p_lock); 432 } 402 433 403 434 // set the new list element's attributes … … 435 466 } 436 467 437 pthread_mutex_unlock(&list->p_lock); 468 if (safeThreads) { 469 pthread_mutex_unlock(&list->p_lock); 470 // pthread_mutex_unlock(&p_lock); 471 } 438 472 439 473 return true; -
trunk/psLib/src/types/psList.h
r6348 r6419 7 7 * @ingroup LinkedList 8 8 * 9 * @version $Revision: 1.3 3$ $Name: not supported by cvs2svn $10 * @date $Date: 2006-02- 07 23:36:15$9 * @version $Revision: 1.34 $ $Name: not supported by cvs2svn $ 10 * @date $Date: 2006-02-10 02:44:46 $ 11 11 * 12 12 * Copyright 2004-2005 Maui High Performance Computing Center, University of Hawaii … … 94 94 ; 95 95 96 /** Private function used by psMemThreadSafety to activate/deactivate thread safety. 97 * 98 * @return bool: The previous value of the thread safety. 99 */ 100 bool p_psListThreadSafety( 101 bool safe ///< current value of thread safety to set 102 ); 96 103 97 104 /** Creates a psList linked list object.
Note:
See TracChangeset
for help on using the changeset viewer.
