IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Changeset 19057


Ignore:
Timestamp:
Aug 13, 2008, 5:22:13 PM (18 years ago)
Author:
Paul Price
Message:

Renamed psThreadTaskDelete to psThreadTaskRemove to maintain consistency with psHash, psMetadata, etc. I'm working on getting some support for thread-specific data. I had a scheme, but it doesn't work (I assumed that a pthread_t was an integer); need to rethink. In the meantime, it's #if-ed out.

Location:
trunk/psLib/src
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • trunk/psLib/src/imageops/psImageConvolve.c

    r19015 r19057  
    77/// @author Eugene Magnier, IfA
    88///
    9 /// @version $Revision: 1.73 $ $Name: not supported by cvs2svn $
    10 /// @date $Date: 2008-08-12 03:08:41 $
     9/// @version $Revision: 1.74 $ $Name: not supported by cvs2svn $
     10/// @date $Date: 2008-08-14 03:22:13 $
    1111///
    1212/// Copyright 2004-2007 Institute for Astronomy, University of Hawaii
     
    10711071        }
    10721072    } else if (!set && threaded) {
    1073         psThreadTaskDelete("PSLIB_IMAGE_CONVOLVE_MASK");
     1073        psThreadTaskRemove("PSLIB_IMAGE_CONVOLVE_MASK");
    10741074    }
    10751075
  • trunk/psLib/src/sys/psThread.c

    r19016 r19057  
    2626static psArray *pool = NULL;            // array of defined threads
    2727static psHash *tasks = NULL;            // List of defined tasks
     28static psArray *tsd = NULL;             // Thread-specific data
    2829
    2930
     
    165166}
    166167
    167 bool psThreadTaskDelete(const char *type)
     168bool psThreadTaskRemove(const char *type)
    168169{
    169170    PS_ASSERT_STRING_NON_EMPTY(type, false);
     
    316317    tasks = NULL;
    317318
     319    psFree(tsd);
     320    tsd = NULL;
     321
    318322    return true;
    319323}
    320324
     325
     326#if 0
     327// This doesn't work like I thought it would: pthread_self can return anything.
     328bool 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
     354void *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
     370bool 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  
    44 *
    55 *  @author EAM, IFA
    6  *  @version $Revision: 1.4 $ $Name: not supported by cvs2svn $
    7  *  @date $Date: 2008-08-12 03:28:37 $
     6 *  @version $Revision: 1.5 $ $Name: not supported by cvs2svn $
     7 *  @date $Date: 2008-08-14 03:22:13 $
    88 *
    99 *  Copyright 2004-2005 Insitute for Astronomy, University of Hawaii
     
    1212#ifndef PS_THREAD_H
    1313#define PS_THREAD_H
     14
     15#include <pthread.h>
     16#include "psString.h"
     17#include "psArray.h"
    1418
    1519/// @addtogroup SysUtils System Utilities
     
    8791
    8892/// Remove a task from the list
    89 bool psThreadTaskDelete(const char *type // Task type to remove
     93bool psThreadTaskRemove(const char *type // Task type to remove
    9094    );
    9195
     
    111115bool psThreadPoolFinalize(void);
    112116
     117
     118/// Add thread-specific data
     119///
     120/// The provided pointer is added to a thread-specific hash under the provided name.
     121bool 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.
     128void *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.
     134bool psThreadDataRemove(const char *name // Name of data
     135    );
     136
     137
    113138/// @}
    114139#endif /* PS_THREAD_H */
Note: See TracChangeset for help on using the changeset viewer.