File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -39,9 +39,7 @@ namespace OS {
3939 resetCursors ();
4040 }
4141 Buffer::~Buffer () {
42- mp_ctx->DecRef ();
43- int ref = mp_ctx->GetRefCount ();
44- if (ref == 0 ) {
42+ if (mp_ctx->DecRef () == 0 ) {
4543 delete mp_ctx;
4644 }
4745 }
Original file line number Diff line number Diff line change @@ -60,8 +60,7 @@ namespace OS {
6060
6161 Buffer &operator =(const Buffer& val) {
6262 if (mp_ctx) {
63- mp_ctx->DecRef ();
64- if (mp_ctx->GetRefCount () == 0 ) {
63+ if (mp_ctx->DecRef () == 0 ) {
6564 delete mp_ctx;
6665 }
6766 }
Original file line number Diff line number Diff line change @@ -137,8 +137,8 @@ void INetPeer::CloseSocket() {
137137}
138138void INetPeer::close_callback (uv_handle_t *handle) {
139139 INetPeer *peer = (INetPeer *)uv_handle_get_data (handle);
140- peer-> DecRef ();
141- if (peer->GetRefCount () == 0 ) {
140+
141+ if (peer->DecRef () == 0 ) {
142142 delete peer;
143143 }
144144
Original file line number Diff line number Diff line change @@ -5,8 +5,8 @@ namespace OS {
55 class Ref {
66 public:
77 Ref () { m_ref_count.store (1 ); };
8- void DecRef () { m_ref_count-- ; };
9- void IncRef () { m_ref_count++ ; };
8+ uint32_t DecRef () { return m_ref_count. fetch_sub ( 1 )- 1 ; };
9+ uint32_t IncRef () { return m_ref_count. fetch_add ( 1 )+ 1 ; };
1010 int GetRefCount () { return m_ref_count.load (); };
1111 private:
1212 std::atomic<uint32_t > m_ref_count;
You can’t perform that action at this time.
0 commit comments