Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 14 additions & 0 deletions include/foonathan/memory/allocator_storage.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -313,6 +313,20 @@ namespace foonathan
{
return StoragePolicy::is_composable();
}

/// @{
/// \effects Explicitly unlocks the \c Mutex.
/// \returns the result of force_unlock() on \c Mutex.
/// \note Only available if \c Mutex supports force_unlock().
/// \note Calling this function can be dangerous, but may be
/// necessary in certain situations (like forcing an allocator
/// to be unlocked in an atfork child handler).
template <typename M = actual_mutex>
auto force_unlock() noexcept -> decltype(std::declval<M&>()->force_unlock())
{
return static_cast<actual_mutex&>(*this)->force_unlock();
}
/// @}
};

/// Tag type that enables type-erasure in \ref reference_storage.
Expand Down
12 changes: 12 additions & 0 deletions include/foonathan/memory/threading.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ namespace foonathan
}

void unlock() noexcept {}
void force_unlock() noexcept {}
};

/// Specifies whether or not a \concept{concept_rawallocator,RawAllocator} is thread safe as-is.
Expand Down Expand Up @@ -79,6 +80,11 @@ namespace foonathan
mutex_.unlock();
}

Mutex * operator->() const noexcept
{
return std::addressof(mutex_);
}

protected:
~mutex_storage() noexcept = default;

Expand All @@ -94,6 +100,12 @@ namespace foonathan

void lock() const noexcept {}
void unlock() const noexcept {}
void force_unlock() const noexcept {}

mutex_storage const * operator->() const noexcept
{
return this;
}

protected:
~mutex_storage() noexcept = default;
Expand Down