Fix copyright lines
[folly.git] / folly / experimental / hazptr / hazptr.h
index 62d96514bc7ade485eb3f9fe8f7b643d07d444f4..5c71b34eefb0289ca81b4b79efadc38a64d4be2c 100644 (file)
@@ -1,5 +1,5 @@
 /*
- * Copyright 2017 Facebook, Inc.
+ * Copyright 2016-present Facebook, Inc.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
@@ -62,7 +62,12 @@ class hazptr_domain {
   hazptr_domain& operator=(const hazptr_domain&) = delete;
   hazptr_domain& operator=(hazptr_domain&&) = delete;
 
+  /** Free-function retire.  May allocate memory */
+  template <typename T, typename D = std::default_delete<T>>
+  void retire(T* obj, D reclaim = {});
+
  private:
+  friend class hazptr_obj_batch;
   friend class hazptr_holder;
   template <typename, typename>
   friend class hazptr_obj_base;
@@ -90,8 +95,13 @@ hazptr_domain& default_hazptr_domain();
 
 extern hazptr_domain default_domain_;
 
+/** Free-function retire, that operates on the default domain */
+template <typename T, typename D = std::default_delete<T>>
+void hazptr_retire(T* obj, D reclaim = {});
+
 /** Definition of hazptr_obj */
 class hazptr_obj {
+  friend class hazptr_obj_batch;
   friend class hazptr_domain;
   template <typename, typename>
   friend class hazptr_obj_base;
@@ -100,7 +110,7 @@ class hazptr_obj {
   friend struct hazptr_priv;
 
   void (*reclaim_)(hazptr_obj*);
-  hazptr_obj* next_;
+  hazptr_obj* next_{nullptr}; // nullptr for debugging
 
   const void* getObjPtr() const;
 };
@@ -120,6 +130,8 @@ class hazptr_obj_base : public hazptr_obj {
 /** Definition of hazptr_recounted_obj_base */
 template <typename T, typename D = std::default_delete<T>>
 class hazptr_obj_base_refcounted : public hazptr_obj {
+  friend class hazptr_obj_batch;
+
  public:
   /* Retire a removed object and pass the responsibility for
    * reclaiming it to the hazptr library */
@@ -140,6 +152,8 @@ class hazptr_obj_base_refcounted : public hazptr_obj {
   bool release_ref();
 
  private:
+  void preRetire(D deleter);
+
   std::atomic<uint32_t> refcount_{0};
   D deleter_;
 };