diff BlockingQueue.h @ 49:083298a6f7b6

new branch PR_univ_lib -- creates a static library, copied to /usr/lib/PR__lib
author Sean Halle <seanhalle@yahoo.com>
date Sat, 27 Jul 2013 13:10:10 -0700
parents 1ea30ca7093c
children
line diff
     1.1 --- a/BlockingQueue.h	Tue Jul 23 07:28:22 2013 -0700
     1.2 +++ b/BlockingQueue.h	Sat Jul 27 13:10:10 2013 -0700
     1.3 @@ -8,7 +8,8 @@
     1.4  #ifndef  _BLOCKINGQUEUE_H
     1.5  #define	_BLOCKINGQUEUE_H
     1.6  
     1.7 -#include "PR__common_includes/PR__primitive_data_types.h"
     1.8 +#include <PR__include/PR__primitive_data_types.h>
     1.9 +#include <PR__include/prmalloc.h>
    1.10  
    1.11  
    1.12  #define TRUE  1
    1.13 @@ -17,76 +18,5 @@
    1.14  #define LOCKED   1
    1.15  #define UNLOCKED 0
    1.16  
    1.17 -
    1.18 -//========== pThreads based queue ==========
    1.19 -/* It is the data that is shared so only need one mutex. */
    1.20 -typedef
    1.21 -struct
    1.22 - { pthread_mutex_t  mutex_t;
    1.23 -   pthread_cond_t   cond_w_t;
    1.24 -   pthread_cond_t   cond_r_t;
    1.25 -   int32            count;
    1.26 -   int32            readPos;
    1.27 -   int32            writePos;
    1.28 -   void*            data[1024];  //an array of pointers
    1.29 -   int w_empty;
    1.30 -   int w_full;
    1.31 - }
    1.32 -PThdQueueStruc;
    1.33 -
    1.34 -PThdQueueStruc*     makePThdQ();
    1.35 -void* readPThdQ( PThdQueueStruc *Q );
    1.36 -void writePThdQ( void *in, PThdQueueStruc *Q );
    1.37 -
    1.38 -
    1.39 -//========== CAS based queue ==========
    1.40 -typedef
    1.41 -struct
    1.42 - { volatile int32   insertLock;
    1.43 -   volatile int32   extractLock;
    1.44 -   volatile void*  *insertPos;
    1.45 -   volatile void*  *extractPos;
    1.46 -   void*   startOfData[1024];  //data is pointers
    1.47 -   void*  *endOfData;          //set when make queue
    1.48 - }
    1.49 -CASQueueStruc;
    1.50 -
    1.51 -CASQueueStruc*  makeCASQ();
    1.52 -void* readCASQ( CASQueueStruc *Q );
    1.53 -void writeCASQ( void *in, CASQueueStruc *Q );
    1.54 -
    1.55 -
    1.56 -//========= non-atomic instr based queue ===========
    1.57 -typedef
    1.58 -struct
    1.59 - { void*  *insertPos;
    1.60 -   void*  *extractPos;
    1.61 -   void*   startOfData[1024];  //data is pointers
    1.62 -   void*  *endOfData;          //set when make queue
    1.63 - }
    1.64 -SRSWQueueStruc;
    1.65 -
    1.66 -SRSWQueueStruc* makeSRSWQ();
    1.67 -void  freeSRSWQ( SRSWQueueStruc* Q );
    1.68 -void* readSRSWQ( SRSWQueueStruc *Q );
    1.69 -void  writeSRSWQ( void *in, SRSWQueueStruc *Q );
    1.70 -
    1.71 -
    1.72 -//========= non-atomic instr S R M W queue ===========
    1.73 -typedef
    1.74 -struct
    1.75 - { int32            lastQReadFrom;
    1.76 -   int32            numInternalQs;
    1.77 -   int32            internalQsSz;
    1.78 -   SRSWQueueStruc* *internalQs;
    1.79 - }
    1.80 -SRMWQueueStruc;
    1.81 -
    1.82 -SRMWQueueStruc* makeSRMWQ();
    1.83 -int addWriterToSRMWQ( SRMWQueueStruc *Q );
    1.84 -void* readSRMWQ( SRMWQueueStruc *Q );
    1.85 -void writeSRMWQ( void *in, SRMWQueueStruc *Q, int writerID );
    1.86 -
    1.87 -
    1.88  #endif	/* _BLOCKINGQUEUE_H */
    1.89