/** hazptr_obj_base */
template <typename T, typename D>
-inline void hazptr_obj_base<T, D>::retire(
- hazptr_domain& domain,
- D deleter,
- const storage_policy /* policy */) {
+inline void hazptr_obj_base<T, D>::retire(hazptr_domain& domain, D deleter) {
DEBUG_PRINT(this << " " << &domain);
deleter_ = std::move(deleter);
reclaim_ = [](hazptr_obj* p) {
/** hazptr_owner */
template <typename T>
-inline hazptr_owner<T>::hazptr_owner(
- hazptr_domain& domain,
- const cache_policy /* policy */) {
+inline hazptr_owner<T>::hazptr_owner(hazptr_domain& domain) {
domain_ = &domain;
hazptr_ = domain_->hazptrAcquire();
DEBUG_PRINT(this << " " << domain_ << " " << hazptr_);
// [TODO]:
// - Thread caching of hazptr_rec-s
// - Private storage of retired objects
+// - Control of reclamation (when and by whom)
// - Optimized memory order
/** Definition of default_hazptr_domain() */
inline hazptr_domain& default_hazptr_domain() {
static hazptr_domain d;
+ DEBUG_PRINT(&d);
return d;
}
/** hazptr_obj */
inline const void* hazptr_obj::getObjPtr() const {
+ DEBUG_PRINT(this);
return this;
}
}
}
-/** hazptr_user */
-
-inline void hazptr_user::flush() {
- DEBUG_PRINT("");
-}
-
-/** hazptr_remover */
-
-inline void hazptr_remover::flush() {
- DEBUG_PRINT("");
-}
-
} // namespace folly
} // namespace hazptr
#include <functional>
#include <memory>
-/* Stand-in for std::pmr::memory_resource */
+/* Stand-in for C++17 std::pmr::memory_resource */
#include <folly/experimental/hazptr/memory_resource.h>
namespace folly {
hazptr_domain& operator=(const hazptr_domain&) = delete;
hazptr_domain& operator=(hazptr_domain&&) = delete;
- void try_reclaim();
-
private:
template <typename, typename>
friend class hazptr_obj_base;
int pushRetired(hazptr_obj* head, hazptr_obj* tail, int count);
void tryBulkReclaim();
void bulkReclaim();
+ void try_reclaim();
};
/** Get the default hazptr_domain */
template <typename T, typename Deleter = std::default_delete<T>>
class hazptr_obj_base : private hazptr_obj {
public:
- /* Policy for storing retired objects */
- enum class storage_policy { priv, shared };
-
/* Retire a removed object and pass the responsibility for
* reclaiming it to the hazptr library */
void retire(
hazptr_domain& domain = default_hazptr_domain(),
- Deleter reclaim = {},
- const storage_policy policy = storage_policy::shared);
+ Deleter reclaim = {});
private:
Deleter deleter_;
* hazard pointers, and interface for hazard pointer operations. */
template <typename T> class hazptr_owner {
public:
- /* Policy for caching hazard pointers */
- enum class cache_policy { cache, nocache };
-
/* Constructor automatically acquires a hazard pointer. */
- explicit hazptr_owner(
- hazptr_domain& domain = default_hazptr_domain(),
- const cache_policy policy = cache_policy::nocache);
-
+ explicit hazptr_owner(hazptr_domain& domain = default_hazptr_domain());
/* Destructor automatically clears and releases the owned hazard pointer. */
~hazptr_owner();
/* Clear the hazard pointer */
void clear() noexcept;
- /* Swap ownership of hazard ponters between hazptr_owner-s. */
+ /* Swap ownership of hazard pointers between hazptr_owner-s. */
/* Note: The owned hazard pointers remain unmodified during the swap
* and continue to protect the respective objects that they were
* protecting before the swap, if any. */
template <typename T>
void swap(hazptr_owner<T>&, hazptr_owner<T>&) noexcept;
-/** hazptr_user: Thread-specific interface for users of hazard
- * pointers (i.e., threads that own hazard pointers by using
- * hazptr_owner. */
-class hazptr_user {
- public:
- /* Release all hazptr_rec-s cached by this thread */
- static void flush();
-};
-
-/** hazptr_remover: Thread-specific interface for removers of objects
- * protected by hazard pointersd, i.e., threads that call the retire
- * member function of hazptr_obj_base. */
-class hazptr_remover {
- public:
- /* Pass responsibility of reclaiming any retired objects stored
- * privately by this thread to the hazptr_domain to which they
- * belong. */
- static void flush();
-};
-
} // namespace hazptr
} // namespace folly