3using System.Collections.Generic;
8using System.Threading.Tasks;
17 object m_objSync =
new object();
18 List<DataItem> m_rgItems =
new List<DataItem>();
19 ManualResetEvent m_evtDataReady =
new ManualResetEvent(
false);
20 ManualResetEvent m_evtAtCount =
new ManualResetEvent(
false);
21 ManualResetEvent m_evtQueryEnd =
new ManualResetEvent(
false);
31 m_nAtCount = nAtCount;
39 get {
return m_rgItems.Count; }
47 get {
return m_evtCancel; }
55 get {
return m_evtQueryEnd; }
66 List<WaitHandle> rgWait =
new List<WaitHandle>();
67 rgWait.AddRange(m_evtCancel.
Handles);
68 rgWait.Add(m_evtAtCount);
69 rgWait.Add(m_evtQueryEnd);
70 WaitHandle[] rgWait1 = rgWait.ToArray();
72 int nWaitItem = WaitHandle.WaitAny(rgWait1, 10);
73 if (nWaitItem == rgWait.Count - 2)
76 Stopwatch sw =
new Stopwatch();
79 while (nWaitItem >= m_evtCancel.
Handles.Length)
81 if (nWaitItem == rgWait.Count - 2)
85 else if (nWaitItem == rgWait.Count - 1)
89 if (m_rgItems.Count == 0)
94 if (sw.Elapsed.TotalMilliseconds > nWait)
97 nWaitItem = WaitHandle.WaitAny(rgWait1, 10);
112 m_evtDataReady.Set();
114 if (m_rgItems.Count >= m_nAtCount)
126 if (!m_evtDataReady.WaitOne(nWait))
132 m_rgItems.RemoveAt(0);
134 if (m_rgItems.Count == 0)
135 m_evtDataReady.
Reset();
137 if (m_rgItems.Count < m_nAtCount)
138 m_evtAtCount.Reset();
151 return m_evtDataReady.WaitOne(nWait);
162 m_evtQueryEnd.Reset();
163 m_evtDataReady.Reset();
164 m_evtAtCount.Reset();
The CancelEvent provides an extension to the manual cancel event that allows for overriding the manua...
WaitHandle[] Handles
Returns the internal wait handle of the CancelEvent.
The DataItemCollection contains the collection of synchronized data items collected from all custom q...
DataItem GetData(int nWait)
Returns the next data item from the back of the queue.
CancelEvent Cancel
Cancels the internal WaitForCount.
ManualResetEvent QueryEnd
The QueryEnd is set when the data reaches the data end.
DataItemCollection(int nAtCount)
The constructor.
int Count
Returns the number of items in the queue.
bool WaitForCount(int nWait)
The WaitForCount function waits for the data queue to either fill to a given number of items (e....
void Add(DataItem di)
Add a new data item to the queue.
void Clear()
The Clear method removes all data from the data queue.
bool WaitData(int nWait)
The WaitData function waits a given amount of time for data to be ready.
The DataItem manages one synchronized data item where the first element is the sync field.
void Reset()
Clears the data fields and the filled status.
The MyCaffe.basecode contains all generic types used throughout MyCaffe.
The MyCaffe.db.stream namespace contains all data streaming related classes.
The MyCaffe namespace contains the main body of MyCaffe code that closesly tracks the C++ Caffe open-...