Changeset 28405 for trunk/psLib
- Timestamp:
- Jun 18, 2010, 2:25:38 PM (16 years ago)
- Location:
- trunk/psLib/src
- Files:
-
- 4 edited
-
imageops/psImageConvolve.c (modified) (7 diffs)
-
imageops/psImageCovariance.c (modified) (2 diffs)
-
sys/psThread.c (modified) (4 diffs)
-
sys/psThread.h (modified) (3 diffs)
Legend:
- Unmodified
- Added
- Removed
-
trunk/psLib/src/imageops/psImageConvolve.c
r28136 r28405 864 864 PS_ARRAY_ADD_SCALAR(job->args, stop, PS_TYPE_S32); 865 865 if (!psThreadJobAddPending(job)) { 866 psFree(job);867 866 psFree(gaussNorm); 868 867 psFree(out); 869 868 return NULL; 870 869 } 871 psFree(job);872 870 } 873 871 if (!psThreadPoolWait(true)) { … … 1213 1211 if (!psThreadJobAddPending(job)) { 1214 1212 psError(PS_ERR_UNKNOWN, false, "Unable to smooth image"); 1215 psFree(job);1216 1213 psFree(calculation); 1217 1214 psFree(calcMask); … … 1219 1216 return false; 1220 1217 } 1221 psFree(job);1222 1218 } 1223 1219 // wait here for the threaded jobs to finish (NOP if threading is not active) … … 1261 1257 if (!psThreadJobAddPending(job)) { 1262 1258 psError(PS_ERR_UNKNOWN, false, "Unable to smooth image"); 1263 psFree(job);1264 1259 psFree(calculation); 1265 1260 psFree(calcMask); … … 1267 1262 return false; 1268 1263 } 1269 psFree(job);1270 1264 } 1271 1265 … … 1580 1574 PS_ARRAY_ADD_SCALAR(job->args, 0x00, PS_TYPE_U8); // specify rows 1581 1575 if (!psThreadJobAddPending(job)) { 1582 psFree(job);1583 1576 psFree(conv); 1584 1577 psFree(out); 1585 1578 return NULL; 1586 1579 } 1587 psFree(job);1588 1580 } 1589 1581 if (!psThreadPoolWait(true)) { … … 1617 1609 PS_ARRAY_ADD_SCALAR(job->args, 0xff, PS_TYPE_U8); // specify cols 1618 1610 if (!psThreadJobAddPending(job)) { 1619 psFree(job);1620 1611 psFree(conv); 1621 1612 psFree(out); 1622 1613 return NULL; 1623 1614 } 1624 psFree(job);1625 1615 } 1626 1616 if (!psThreadPoolWait(true)) { -
trunk/psLib/src/imageops/psImageCovariance.c
r28152 r28405 169 169 return NULL; 170 170 } 171 psFree(job);172 171 } else { 173 172 out->kernel[y][x] = imageCovarianceCalculate(covar, kernel, x, y); … … 334 333 return NULL; 335 334 } 336 psFree(job);337 335 } else { 338 336 out->kernel[y][x] = imageCovarianceBin(covar, bin, binVal, x, y); -
trunk/psLib/src/sys/psThread.c
r28402 r28405 99 99 bool psThreadJobAddPending(psThreadJob *job) 100 100 { 101 PS_ASSERT_THREAD_JOB_NON_NULL(job, false); 101 if (!job) { 102 // Asking for a no-op 103 return true; 104 } 102 105 103 106 psThreadTask *task = psHashLookup(tasks, job->type); // Task to execute job … … 114 117 } 115 118 psListAdd(done, PS_LIST_TAIL, job); 116 119 psFree(job); 117 120 return task->function(job); 118 121 } … … 123 126 } 124 127 psListAdd(pending, PS_LIST_TAIL, job); 128 psFree(job); 125 129 psThreadUnlock(); 126 130 … … 279 283 for (int i = 0; i < nThreads; i++) { 280 284 psThread *thread = pool->data[i] = psThreadAlloc(); // Thread for pool 281 if ( !pthread_create(&threads[i], NULL, psThreadLauncher, thread)) {285 if (pthread_create(&threads[i], NULL, psThreadLauncher, thread)) { 282 286 psAbort("Unable to create thread"); 283 287 } -
trunk/psLib/src/sys/psThread.h
r28402 r28405 73 73 74 74 /// Add a pending job to the queue 75 /// 76 /// This function swallows the provided job, so that the user no longer owns it. This is because freeing the 77 /// job is not thread-safe (its reference count is being changed within the threads) so we handle it ourselves 78 /// and absolve the user from all responsibility. If the user stores the job, he should only access it while 79 /// threads are processing in code protected by psThreadLock/psThreadUnlock. 75 80 bool psThreadJobAddPending(psThreadJob *job); 76 81 77 82 /// Get a job off the queue of pending jobs 83 /// 84 /// This function is not thread-safe. Protect with psThreadLock/psThreadUnlock if threads are running. 78 85 psThreadJob *psThreadJobGetPending(void); 79 86 80 87 /// Get a job off the queue of done jobs 88 /// 89 /// This function is not thread-safe. Protect with psThreadLock/psThreadUnlock if threads are running. 81 90 psThreadJob *psThreadJobGetDone(void); 82 91 … … 115 124 bool psThreadPoolFinalize(void); 116 125 117 126 #if 0 118 127 /// Add thread-specific data 119 128 /// … … 134 143 bool psThreadDataRemove(const char *name // Name of data 135 144 ); 136 145 #endif 137 146 138 147 /// @}
Note:
See TracChangeset
for help on using the changeset viewer.
