/*
- * 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.
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;
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;
friend struct hazptr_priv;
void (*reclaim_)(hazptr_obj*);
- hazptr_obj* next_;
+ hazptr_obj* next_{nullptr}; // nullptr for debugging
const void* getObjPtr() const;
};
/** 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 */
bool release_ref();
private:
+ void preRetire(D deleter);
+
std::atomic<uint32_t> refcount_{0};
D deleter_;
};