| OLD | NEW |
| 1 /* | 1 /* |
| 2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
| 3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
| 4 * | 4 * |
| 5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
| 6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
| 7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
| 8 * | 8 * |
| 9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
| 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
| (...skipping 26 matching lines...) Expand all Loading... |
| 37 class ref_counted | 37 class ref_counted |
| 38 { | 38 { |
| 39 public: | 39 public: |
| 40 void AddRef() | 40 void AddRef() |
| 41 { | 41 { |
| 42 mRefCount++; | 42 mRefCount++; |
| 43 } | 43 } |
| 44 | 44 |
| 45 void ReleaseRef() | 45 void ReleaseRef() |
| 46 { | 46 { |
| 47 assert2(mRefCount > 0, u"Unexpected zero or negative reference count"_str); | 47 assert2(mRefCount > 0, ABP_TEXT("Unexpected zero or negative reference count
"_str)); |
| 48 if (--mRefCount == 0) | 48 if (--mRefCount == 0) |
| 49 delete this; | 49 delete this; |
| 50 } | 50 } |
| 51 | 51 |
| 52 protected: | 52 protected: |
| 53 ref_counted() | 53 ref_counted() |
| 54 : mRefCount(1) | 54 : mRefCount(1) |
| 55 { | 55 { |
| 56 } | 56 } |
| 57 | 57 |
| 58 virtual ~ref_counted() | 58 virtual ~ref_counted() |
| 59 { | 59 { |
| 60 assert2(mRefCount == 0, u"Destroying a ref-counted object with a non-zero re
ference count"_str); | 60 assert2(mRefCount == 0, ABP_TEXT("Destroying a ref-counted object with a non
-zero reference count"_str)); |
| 61 } | 61 } |
| 62 | 62 |
| 63 private: | 63 private: |
| 64 int mRefCount; | 64 int mRefCount; |
| 65 }; | 65 }; |
| 66 | 66 |
| 67 template<typename T> | 67 template<typename T> |
| 68 class intrusive_ptr | 68 class intrusive_ptr |
| 69 { | 69 { |
| 70 static_assert(std::is_base_of<ref_counted, T>::value, "The class T should inhe
rit ref_counted"); | 70 static_assert(std::is_base_of<ref_counted, T>::value, "The class T should inhe
rit ref_counted"); |
| (...skipping 145 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
| 216 return a == b.get(); | 216 return a == b.get(); |
| 217 } | 217 } |
| 218 | 218 |
| 219 template<typename T, typename U> | 219 template<typename T, typename U> |
| 220 inline bool operator!=(const T* a, intrusive_ptr<U> const& b) | 220 inline bool operator!=(const T* a, intrusive_ptr<U> const& b) |
| 221 { | 221 { |
| 222 return a != b.get(); | 222 return a != b.get(); |
| 223 } | 223 } |
| 224 | 224 |
| 225 ABP_NS_END | 225 ABP_NS_END |
| OLD | NEW |