面向物件鎖框架的設計與實現
阿新 • • 發佈:2018-12-27
{
9 typedef U<T> Allocator;
10 typedef C<T,Allocator> cont_type;
11 typedef stl_sequence<T,L,E,C,U> self_type;
12 typedef E<self_type,L> base_type;
13 typedef typename base_type::lock_guard_type lock_guard_type;14
15public:
16
17 void add(const T &t,bool append =true)
18 {
19 lock_guard_type guard(*this);
20 //do add thing21 }22
23 void insert(size_t idx,const T &t)
24 {
25 lock_guard_type guard(*this);
26 //do insert thing27 }28
29 void erase(size_t idx)
30 {
31 lock_guard_type guard( *this);
32 //do erase thing33 }34
35 T*get(size_t idx)
36 {
37 lock_guard_type guard(*this);
38 //do get thing39 }40
41}
9 typedef U<T> Allocator;
10 typedef C<T,Allocator> cont_type;
11 typedef stl_sequence<T,L,E,C,U> self_type;
12 typedef E<self_type,L> base_type;
13 typedef typename base_type::lock_guard_type lock_guard_type;14
15public:
16
17 void add(const
18 {
19 lock_guard_type guard(*this);
20 //do add thing21 }22
23 void insert(size_t idx,const T &t)
24 {
25 lock_guard_type guard(*this);
26 //do insert thing27 }28
29 void erase(size_t idx)
30 {
31 lock_guard_type guard(
32 //do erase thing33 }34
35 T*get(size_t idx)
36 {
37 lock_guard_type guard(*this);
38 //do get thing39 }40
41}