IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
May 18, 2010, 12:49:05 PM (16 years ago)
Author:
eugene
Message:

merging changes from trunk into branches/pap

Location:
branches/pap
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • branches/pap

  • branches/pap/psModules/src/objects/pmSourceFitSet.c

    r25754 r28003  
    6262    // before pmSourceFitSetInit is called
    6363    for (int i = 0; i < fitSets->n; i++) {
    64         psAssert (fitSets->data[i] == NULL, "failure to init or clear fitSets?");
     64        psAssert(fitSets->data[i] == NULL, "failure to init or clear fitSets?");
    6565    }
    6666    return true;
     
    6868
    6969void pmSourceFitSetDone (void) {
    70     psFree (fitSets);
     70    psFree(fitSets);
     71    fitSets = NULL;
    7172}
    7273
     
    113114}
    114115
    115 pmSourceFitSetData *pmSourceFitSetDataSet (psArray *modelSet) {
    116 
    117     pmSourceFitSetData *thisSet = NULL;
    118 
    119     psAssert (fitSets, "pmSourceFitSetInit not called");
     116pmSourceFitSetData *pmSourceFitSetDataSet (psArray *modelSet)
     117{
     118    psAssert(fitSets, "pmSourceFitSetInit not called");
    120119
    121120    // find the fitSet used by this thread
    122121    pthread_t id = pthread_self();
    123122
    124     // is our ID is already on the stack, abort.
    125     // we do not need to lock to do this....
     123    // If our ID is already on the stack, abort.
     124    // We do need to lock on this because someone might pull one of the fitSets out from under us
     125    pthread_mutex_lock(&fitSetInitMutex);
    126126    for (int i = 0; i < fitSets->n; i++) {
    127         thisSet = fitSets->data[i];
     127        pmSourceFitSetData *thisSet = fitSets->data[i];
    128128        if (!thisSet) continue;
    129129        if (thisSet->thread == id) {
    130             break;
    131         }
    132         thisSet = NULL;
    133     }
    134     psAssert (thisSet == NULL, "pmSourceFitSetDataSet() called but previous entry not cleared");
    135 
    136     thisSet = pmSourceFitSetDataAlloc(modelSet);
    137 
    138     pthread_mutex_lock (&fitSetInitMutex);
    139 
    140     // find an entry that is NULL and place it there
     130            psAbort("pmSourceFitSetDataSet() called but previous entry not cleared");
     131        }
     132    }
     133
     134    // Find an open slot
    141135    for (int i = 0; i < fitSets->n; i++) {
    142136        if (fitSets->data[i]) continue;
    143         fitSets->data[i] = thisSet;
    144         pthread_mutex_unlock (&fitSetInitMutex);
     137        pmSourceFitSetData *thisSet = fitSets->data[i] = pmSourceFitSetDataAlloc(modelSet);
     138        pthread_mutex_unlock(&fitSetInitMutex);
    145139        return thisSet;
    146140    }
    147     pthread_mutex_unlock (&fitSetInitMutex);
    148     psAbort ("no empty slot for new pmSourceFitSetData");
     141    pthread_mutex_unlock(&fitSetInitMutex);
     142    psAbort("no empty slot for new pmSourceFitSetData");
    149143    return NULL;
    150144}
     
    152146pmSourceFitSetData *pmSourceFitSetDataGet (void) {
    153147
    154     psAssert (fitSets, "pmSourceFitSetInit not called");
    155 
    156     // find the fitSet used by this thread
     148    psAssert(fitSets, "pmSourceFitSetInit not called");
     149
     150    // Find the fitSet used by this thread
     151    // We do need to lock on this because someone might pull one of the fitSets out from under us
    157152    pthread_t id = pthread_self();
    158 
    159     // can we find our fitSet?  we do not need to lock to do this....
    160     pmSourceFitSetData *thisSet = NULL;
     153    pthread_mutex_lock(&fitSetInitMutex);
    161154    for (int i = 0; i < fitSets->n; i++) {
    162         thisSet = fitSets->data[i];
     155        pmSourceFitSetData *thisSet = fitSets->data[i];
    163156        if (!thisSet) continue;
    164157        if (thisSet->thread == id) {
    165             break;
    166         }
    167         thisSet = NULL;
    168     }
    169     psAssert (thisSet != NULL, "pmSourceFitSetDataGet() called, but no entry found");
    170 
    171     return thisSet;
    172 }
    173 
    174 void pmSourceFitSetDataClear (void) {
    175 
    176     int i;
    177 
     158            pthread_mutex_unlock(&fitSetInitMutex);
     159            return thisSet;
     160        }
     161    }
     162    psAbort("pmSourceFitSetDataGet() called, but no entry found");
     163}
     164
     165void pmSourceFitSetDataClear (void)
     166{
    178167    psAssert (fitSets, "pmSourceFitSetInit not called");
    179168
    180     // find the fitSet used by this thread
     169    // Find the fitSet used by this thread
     170    // We do need to lock on this because someone might pull one of the fitSets out from under us
    181171    pthread_t id = pthread_self();
    182 
    183     // can we find our fitSet?  we do not need to lock to do this....
    184     pmSourceFitSetData *thisSet = NULL;
    185     for (i = 0; i < fitSets->n; i++) {
    186         thisSet = fitSets->data[i];
     172    pthread_mutex_lock(&fitSetInitMutex);
     173    for (int i = 0; i < fitSets->n; i++) {
     174        pmSourceFitSetData *thisSet = fitSets->data[i];
    187175        if (!thisSet) continue;
    188176        if (thisSet->thread == id) {
    189             break;
    190         }
    191         thisSet = NULL;
    192     }
    193     psAssert (thisSet != NULL, "pmSourceFitSetDataClear() called, but no entry found");
    194 
    195     psFree (thisSet);
    196     fitSets->data[i] = NULL;
     177            psFree(thisSet);
     178            fitSets->data[i] = NULL;
     179            pthread_mutex_unlock(&fitSetInitMutex);
     180            return;
     181        }
     182    }
     183    psAbort("pmSourceFitSetDataClear() called, but no entry found");
     184
    197185    return;
    198186}
     
    481469
    482470            // Convert i/j to image space:
    483             // 0.5 PIX: the coordinate values must be in pixel coords, not index           
     471            // 0.5 PIX: the coordinate values must be in pixel coords, not index
    484472            coord->data.F32[0] = (psF32) (j + 0.5 + source->pixels->col0);
    485473            coord->data.F32[1] = (psF32) (i + 0.5 + source->pixels->row0);
Note: See TracChangeset for help on using the changeset viewer.