template <typename M, typename T = std::deque<M>> //M 元素类型 , T STL容器
struct Node
{
virtual void add(M m) = 0;
virtual void erase(M m) = 0;
void Add(M m)
{
WRITE_LOCK(__t);
add(m);
}
void Erase(M m)
{
WRITE_LOCK(__t);
erase(m);
}
protected:
RWObject<T> __t; //读写锁< 容器<元素> >
}
struct Node1 : public Node<int, std::deque<int>> //std::deque<int> 线程安全类
{
void add(int a)
{
__t.push_back(a);
}
void erase(int a) {}
};
struct Node2 : public Node<Node1, std::deque<Node1>> //std::deque<std::deque<int>> 线程安全类
{
void add(Node1 a) {}
void erase(Node1 a) {}
};