Develop and Download Open Source Software

Browse Subversion Repository

Annotation of /WinCS/TaskManager.cpp

Parent Directory Parent Directory | Revision Log Revision Log


Revision 11 - (hide annotations) (download) (as text)
Wed Feb 10 18:21:00 2010 UTC (14 years, 2 months ago) by sho1get
File MIME type: text/x-c++src
File size: 1445 byte(s)


1 sho1get 11 #include "StdAfx.h"
2     #include "TaskManager.h"
3    
4     //////////////////////////////////////////////////////////////////////////
5    
6     CTaskManager::CTaskManager()
7     {
8     m_hTimer = NULL;
9     m_DataQueue.nCount = 0;
10     m_DataQueue.nIndex = 0;
11     m_DataQueue.nPoint = 0;
12     }
13    
14     CTaskManager::~CTaskManager()
15     {
16     }
17    
18     void CTaskManager::InitDataQueue()
19     {
20     CSingleLock sl(&m_DataQueue.cs, TRUE);
21    
22     m_DataQueue.nCount = 0;
23     m_DataQueue.nIndex = 0;
24     m_DataQueue.nPoint = 0;
25    
26     for (UINT i = 0; i < 1000; i++)
27     {
28     m_DataQueue.Queue[i].RemoveAll();
29     }
30     }
31    
32     BOOL CTaskManager::DataEnqueue(const CByteArray &data)
33     {
34     CSingleLock sl(&m_DataQueue.cs, TRUE);
35    
36     if (m_DataQueue.nCount < WCS_QUEUE_SIZE)
37     {
38     m_DataQueue.Queue[m_DataQueue.nIndex].Copy(data);
39     m_DataQueue.nCount++;
40     m_DataQueue.nIndex = (m_DataQueue.nIndex + 1) % WCS_QUEUE_SIZE;
41     return TRUE;
42     }
43    
44     return FALSE;
45     }
46    
47     BOOL CTaskManager::DataDequeue(CByteArray &data)
48     {
49     CSingleLock sl(&m_DataQueue.cs, TRUE);
50    
51     if (m_DataQueue.nCount > 0)
52     {
53     data.Copy(m_DataQueue.Queue[m_DataQueue.nPoint]);
54     m_DataQueue.Queue[m_DataQueue.nPoint].RemoveAll();
55     m_DataQueue.nCount--;
56     m_DataQueue.nPoint = (m_DataQueue.nPoint + 1) % WCS_QUEUE_SIZE;
57     return TRUE;
58     }
59    
60     return FALSE;
61     }
62    
63     int CTaskManager::GetQueueSize()
64     {
65     CSingleLock sl(&m_DataQueue.cs, TRUE);
66     return m_DataQueue.nCount;
67     }
68    
69     //////////////////////////////////////////////////////////////////////////

Back to OSDN">Back to OSDN
ViewVC Help
Powered by ViewVC 1.1.26