Jeff 5 anos atrás
pai
commit
7ef940337b
1 arquivos alterados com 84 adições e 0 exclusões
  1. 84 0
      scbc.tools/scbc.tools/SafeList.h

+ 84 - 0
scbc.tools/scbc.tools/SafeList.h

@@ -0,0 +1,84 @@
+#ifndef __SAFE_LIST__
+#define __SAFE_LIST__
+
+#include <list>
+#include <locale.h>
+#include "CritSection.h"
+class CDatabase;
+using namespace std;
+
+template <class _Ty,class _Ax = allocator<_Ty>>
+class SafeList: public std::list<_Ty, _Ax>
+{
+public:
+	ThreadSection _critSection;
+	void _push_back(const _Ty& _Val)
+	{
+		AutoThreadSection aSection(&_critSection);
+		push_back(_Val);
+	}
+
+	void _push_front(const _Ty& _Val)
+	{
+		AutoThreadSection aSection(&_critSection);
+		push_front(_Val);
+	}
+
+	void _pop_front()
+	{
+		AutoThreadSection aSection(&_critSection);
+		pop_front();
+	}
+
+	CDatabase* _pop_front_()
+	{
+		AutoThreadSection aSection(&_critSection);
+		CDatabase* it = front();
+		pop_front();
+		return it;
+	}
+
+	void _pop_back()
+	{
+		AutoThreadSection aSection(&_critSection);
+		pop_back();
+	}
+
+	void _remove(const _Ty& _Val_arg)
+	{
+		AutoThreadSection aSection(&_critSection);
+		remove(_Val_arg);
+	}
+
+	reference _front()
+	{
+		AutoThreadSection aSection(&_critSection);
+		return (*begin());
+	}
+
+	const_reference _front() const
+	{	
+		AutoThreadSection aSection(&_critSection);
+		return (*begin());
+	}
+
+	reference _back()
+	{	
+		AutoThreadSection aSection(&_critSection);
+		return (*(--end()));
+	}
+
+	const_reference _back() const
+	{	
+		AutoThreadSection aSection(&_critSection);
+		return (*(--end()));
+	}
+
+	size_type _size()
+	{	
+		//AutoThreadSection aSection(&_critSection);
+		return size();
+	}
+};
+
+#endif // __SAFE_LIST__