IPP Software Navigation Tools IPP Links Communication Pan-STARRS Links

Ignore:
Timestamp:
Aug 18, 2006, 1:44:51 PM (20 years ago)
Author:
eugene
Message:

successful implementation of the threaded version of pcontrol

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/Ohana/src/opihi/pcontrol/StackOps.c

    r8296 r8424  
    2525  ALLOCATE (stack[0].id,     int,    stack[0].NOBJECT);
    2626
    27   // we need to use a mutex of type
    28   // stack[0].mutex = PTHREAD_MUTEX_INITIALIZER;
    29 
     27# ifdef THREADED
     28  pthread_mutex_init (&stack[0].mutex, NULL);
     29# endif
    3030  return (stack);
    3131}
     
    7272void *PullStackByLocation (Stack *stack, int where) {
    7373
    74   int i;
    7574  void *object;
    7675 
     
    9695void *PullStackByName (Stack *stack, char *name) {
    9796
    98   int i, j;
     97  int i;
    9998  void *object;
    10099
     
    106105    /* here is the element of interest */
    107106    object = stack[0].object[i];
    108     RemoveStackEntry (i);
     107    RemoveStackEntry (stack, i);
    109108    UnlockStack (stack);
    110109    return (object);
     
    117116void *PullStackByID (Stack *stack, int id) {
    118117
    119   int i, j;
     118  int i;
    120119  void *object;
    121120 
     
    137136/* should only be called if you know where is a valid entry */
    138137int RemoveStackEntry (Stack *stack, int where) {
     138
     139  int i;
    139140
    140141  if (where < 0) abort();
     
    152153}
    153154
    154 /* should only be called if manually lock the stack */
    155 int RemoveStackByID (Stack *stack, int id) {
    156 
    157   int i, j;
     155/* should only be called if you manually lock the stack */
     156void *RemoveStackByID (Stack *stack, int id) {
     157
     158  int i;
    158159  void *object;
    159160 
     
    205206
    206207void LockStack (Stack *stack) {
     208# ifdef THREADED
     209  pthread_mutex_lock (&stack[0].mutex);
     210# endif
    207211  return;
    208212}
    209213
    210214void UnlockStack (Stack *stack) {
     215# ifdef THREADED
     216  pthread_mutex_unlock (&stack[0].mutex);
     217# endif
    211218  return;
    212219}
    213 
    214 // Safe with PTHREAD_MUTEX_INITIALIZER lock
Note: See TracChangeset for help on using the changeset viewer.