/*************************************************************************** Fixed size Queue Class Header ( FixedQueue.h ) ----------------------------------------- begin : 2013/08/09 copyright : (C) 2005 SolutionBox Inc. author : Development 1 Team email : dev1@solbox.com version : 3.2 CopyRight(C) 2005 SolutionBox Inc. All Rights reserved. Redistribution and use in source and binary forms, with or with out modification, are not permitted in outside of SolutionBox Inc. ***************************************************************************/ #ifndef __FIXED_SIZE_QUEUE_H__ #define __FIXED_SIZE_QUEUE_H__ #include #include class CMutexLock { public: CMutexLock(pthread_mutex_t * mutex); ~CMutexLock(); private: pthread_mutex_t* m_plock; }; class FixedQueueData { public: size_t data_size; char * data; FixedQueueData () : data_size(0), data(NULL) {}; ~FixedQueueData () { if(data) delete [] data; } }; class CFixedQueue { public: ///@brief »ý¼ºÀÚ. ///@param bufferSize [in] µ¥ÀÌÅÍ ¹öÆÛ Å©±â ///@param qSzie [in] Å¥ÀÇ Å©±â CFixedQueue (int bufferSize, int qSzie ); ///@brief ¼Ò¸êÀÚ. ~CFixedQueue(); ///@brief µ¥ÀÌÅÍ »ðÀÔ ///@param buf [in] µ¥ÀÌÅÍ ///@param buffersize [in] µ¥ÀÌÅÍ Å©±â ///@return 0: Á¤»ó, 1:queue full, -1 : error int Push(char* buf, size_t buffersize); ///@brief µ¥ÀÌÅÍ ÃßÃâ ///@return µ¥ÀÌÅÍ ¸®ÅÏ(FIFO) ///@param buf [in] µ¥ÀÌÅÍ ///@param buffersize [in] µ¥ÀÌÅÍ Å©±â ///@return 0: Á¤»ó, 1: queue empty ³ª¸ÓÁö : error int Pop(char* buf, size_t buffersize); protected: ///@brief Å¥¿¡ ÃʱâÈ­ void ReleaseAll(); private: int m_bufferSize; int m_queueSize; pthread_mutex_t m_mutex; std::queue m_queue; }; #endif // __FIXED_SIZE_QUEUE_H__