123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- #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__
|