/[resiprocate]/branches/b-identity-0505/dum/RefCountedDestroyer.hxx
ViewVC logotype

Annotation of /branches/b-identity-0505/dum/RefCountedDestroyer.hxx

Parent Directory Parent Directory | Revision Log Revision Log


Revision 3138 - (hide annotations) (download)
Thu Jul 22 18:29:17 2004 UTC (15 years, 6 months ago) by derek
Original Path: main/sip/resiprocate/dum/RefCountedDestroyer.hxx
File size: 1363 byte(s)
Some fixes to Refer/ServerSubcription
180s with to tags and w/out contacts are handled
ServerInviteSession now guards against mid-dispatch deletion
DialogSet::Cancel can now cancel an invite w/out recieved a 18x.
1 derek 3138 #if !defined(RESIP_REFCOUNTEDDESTROYER_HXX)
2     #define RESIP_REFCOUNTEDDESTROYER_HXX
3    
4     namespace resip
5     {
6    
7     //designed to be used by composition, does not destroy itself.
8     template<class T>
9     class RefCountedDestroyer
10     {
11     public:
12     class Guard
13     {
14     public:
15     void destroy()
16     {
17     mRefCountedDestroyer.mDestroying = true;
18     }
19    
20     bool destroyed()
21     {
22     return mRefCountedDestroyer.mDestroying;
23     }
24    
25     Guard(RefCountedDestroyer& rcd)
26     : mRefCountedDestroyer(rcd)
27     {
28     mRefCountedDestroyer.mCount++;
29     }
30    
31     ~Guard()
32     {
33     mRefCountedDestroyer.mCount--;
34     if (mRefCountedDestroyer.mDestroying && mRefCountedDestroyer.mCount == 0)
35     {
36     delete mRefCountedDestroyer.mTarget;
37     }
38     }
39     private:
40     RefCountedDestroyer& mRefCountedDestroyer;
41     };
42    
43     RefCountedDestroyer(T* target) :
44     mTarget(target),
45     mCount(0),
46     mDestroying(false)
47     {
48     }
49     private:
50     friend class Guard;
51     T* mTarget;
52     int mCount;
53     bool mDestroying;
54     };
55    
56     }
57    
58     #endif

webmaster AT resiprocate DOT org
ViewVC Help
Powered by ViewVC 1.1.27