File tree Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Expand file tree Collapse file tree 2 files changed +11
-12
lines changed Original file line number Diff line number Diff line change 1
1
---
2
- refs/heads/master: 73cc624e8e326f54eb0ea8bff70388d62dccd3cb
2
+ refs/heads/master: 02a5949abaa4e888ecb470023ea2f29cd6bde43b
Original file line number Diff line number Diff line change @@ -97,19 +97,18 @@ static intptr_t const CONST_REFCOUNT = 0x7badface;
97
97
static size_t const BUF_BYTES = 2048 ;
98
98
99
99
// Every reference counted object should derive from this base class.
100
+ // Or use this macro. The macro is preferred as the base class will be
101
+ // disappearing.
100
102
101
- template < typename T> struct rc_base {
102
- intptr_t ref_count;
103
-
104
- void ref () {
105
- ++ref_count;
106
- }
103
+ # define RUST_REFCOUNTED ( T ) \
104
+ RUST_REFCOUNTED_WITH_DTOR (T, delete (T*)this)
105
+ # define RUST_REFCOUNTED_WITH_DTOR ( T, dtor ) \
106
+ intptr_t ref_count; \
107
+ void ref () { ++ref_count; } \
108
+ void deref () { if (--ref_count == 0 ) { dtor; } }
107
109
108
- void deref () {
109
- if (--ref_count == 0 ) {
110
- delete (T*)this ;
111
- }
112
- }
110
+ template <typename T> struct rc_base {
111
+ RUST_REFCOUNTED (T)
113
112
114
113
rc_base ();
115
114
~rc_base ();
You can’t perform that action at this time.
0 commit comments