AK: Decorate RefCountedBase::try_ref with nodiscard

Because try_ref only increments the ref count if it returned true,
it is important that any caller properly acts upon the return value.
This commit is contained in:
Tom 2021-01-03 16:41:49 -07:00 committed by Andreas Kling
parent 4adfdb98aa
commit a6c459dd29

View file

@ -74,7 +74,7 @@ public:
ASSERT(!Checked<RefCountType>::addition_would_overflow(old_ref_count, 1));
}
ALWAYS_INLINE bool try_ref() const
[[nodiscard]] ALWAYS_INLINE bool try_ref() const
{
RefCountType expected = m_ref_count.load(AK::MemoryOrder::memory_order_relaxed);
for (;;) {