PtrFifo.cpp
上传用户:zjb_0001
上传日期:2007-01-11
资源大小:154k
文件大小:1k
源码类别:

Audio

开发平台:

Visual C++

  1. // PtrFIFO.cpp: implementation of the CPtrFIFO class.
  2. //
  3. //////////////////////////////////////////////////////////////////////
  4. #include "stdafx.h"
  5. #include "fister.h"
  6. #include "PtrFIFO.h"
  7. #ifdef _DEBUG
  8. #undef THIS_FILE
  9. static char THIS_FILE[]=__FILE__;
  10. #define new DEBUG_NEW
  11. #endif
  12. //////////////////////////////////////////////////////////////////////
  13. // Construction/Destruction
  14. //////////////////////////////////////////////////////////////////////
  15. CPtrFIFO::CPtrFIFO()
  16. {
  17. m_pSemaphore = new CSemaphore(0, 10000);
  18. }
  19. CPtrFIFO::~CPtrFIFO()
  20. {
  21. // this will also free the memory
  22. CPtrList::RemoveAll();
  23. delete m_pSemaphore;
  24. }
  25. void CPtrFIFO::Add(void *newElement)
  26. {
  27. CPtrList::AddTail(newElement);
  28. m_pSemaphore->Unlock();
  29. }
  30. void* CPtrFIFO::Consume()
  31. {
  32. m_pSemaphore->Lock();
  33. return CPtrList::RemoveHead();
  34. }