00001 #ifndef PTHR_WRITER_BUF_POOL_H 00002 #define PTHR_WRITER_BUF_POOL_H 00003 00004 #include "DistBossUtil/AutoEnlargeBuffer.h" 00005 #include "IRawFile/RawFileExceptions.h" 00006 #include "IRawFile/IRawWriter.h" 00007 #include <semaphore.h> 00008 #include <pthread.h> 00009 00010 template <typename Writer, int PoolSize = 8> 00011 class PthrWriterBufPool : virtual IRawWriter 00012 { 00013 public : 00014 00015 PthrWriterBufPool(typename Writer::WriterArgType& arg); 00016 virtual ~PthrWriterBufPool(); 00017 00018 int writeEvent(void* pevt, int size); 00019 int stat(); 00020 00021 00022 private : 00023 00024 static void* thread_writing(void* arg); 00025 00026 PthrWriterBufPool(); //stop default 00027 00028 00029 private : 00030 00031 int m_inLoop; 00032 int m_outLoop; 00033 AutoEnlargeBuffer* m_buf[PoolSize]; 00034 00035 Writer* m_writer; 00036 00037 pthread_t m_tid; 00038 sem_t m_semIn; 00039 sem_t m_semOut; 00040 00041 sem_t m_semFinalize; 00042 }; 00043 00044 #include "DistBossUtil/template/PthrWriterBufPool.cc" 00045 00046 #endif