12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #ifndef SHARE_GC_Z_ZSAFEDELETE_HPP 25 #define SHARE_GC_Z_ZSAFEDELETE_HPP 26 27 #include "gc/z/zArray.hpp" 28 #include "gc/z/zLock.hpp" 29 #include "metaprogramming/removeExtent.hpp" 30 31 template <typename T> 32 class ZSafeDelete { 33 private: 34 typedef typename RemoveExtent<T>::type ItemT; 35 36 ZLock _lock; 37 uint64_t _enabled; 38 ZArray<ItemT*> _deferred; 39 40 bool deferred_delete(ItemT* item); 41 void immediate_delete(ItemT* item); 42 43 public: 44 ZSafeDelete(); 45 46 void enable_deferred_delete(); 47 void disable_deferred_delete(); 48 49 void operator()(ItemT* item); 50 }; 51 52 #endif // SHARE_GC_Z_ZSAFEDELETE_HPP | 12 * version 2 for more details (a copy is included in the LICENSE file that 13 * accompanied this code). 14 * 15 * You should have received a copy of the GNU General Public License version 16 * 2 along with this work; if not, write to the Free Software Foundation, 17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 18 * 19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA 20 * or visit www.oracle.com if you need additional information or have any 21 * questions. 22 */ 23 24 #ifndef SHARE_GC_Z_ZSAFEDELETE_HPP 25 #define SHARE_GC_Z_ZSAFEDELETE_HPP 26 27 #include "gc/z/zArray.hpp" 28 #include "gc/z/zLock.hpp" 29 #include "metaprogramming/removeExtent.hpp" 30 31 template <typename T> 32 class ZSafeDeleteImpl { 33 private: 34 typedef typename RemoveExtent<T>::type ItemT; 35 36 ZLock* _lock; 37 uint64_t _enabled; 38 ZArray<ItemT*> _deferred; 39 40 bool deferred_delete(ItemT* item); 41 void immediate_delete(ItemT* item); 42 43 public: 44 ZSafeDeleteImpl(ZLock* lock); 45 46 void enable_deferred_delete(); 47 void disable_deferred_delete(); 48 49 void operator()(ItemT* item); 50 }; 51 52 template <typename T> 53 class ZSafeDelete : public ZSafeDeleteImpl<T> { 54 private: 55 ZLock _lock; 56 57 public: 58 ZSafeDelete(); 59 }; 60 61 template <typename T> 62 class ZSafeDeleteNoLock : public ZSafeDeleteImpl<T> { 63 public: 64 ZSafeDeleteNoLock(); 65 }; 66 67 #endif // SHARE_GC_Z_ZSAFEDELETE_HPP |