Commit a93eb033 authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook Github Bot

Add unsafe-unlocked getter to Synchronized

Summary:
[Folly] Add unsafe-unlocked getter to `Synchronized`.

Provided as a backdoor for call-sites where it is known safe to be used. For example, when it is known that only one thread has access to the `Synchronized` instance.

To be used with care - this method explicitly overrides the normal safety guarantees provided by the rest of the `Synchronized` API.

Reviewed By: chadaustin, simpkins

Differential Revision: D8178205

fbshipit-source-id: 648ee392a43a06333452f72d992ec42ba4a1a73c
parent 47fa124a
...@@ -777,6 +777,23 @@ struct Synchronized : public SynchronizedBase< ...@@ -777,6 +777,23 @@ struct Synchronized : public SynchronizedBase<
return datum_; return datum_;
} }
/**
* Returns a reference to the datum without acquiring a lock.
*
* Provided as a backdoor for call-sites where it is known safe to be used.
* For example, when it is known that only one thread has access to the
* Synchronized instance.
*
* To be used with care - this method explicitly overrides the normal safety
* guarantees provided by the rest of the Synchronized API.
*/
T& unsafeGetUnlocked() {
return datum_;
}
const T& unsafeGetUnlocked() const {
return datum_;
}
private: private:
template <class LockedType, class MutexType, class LockPolicy> template <class LockedType, class MutexType, class LockPolicy>
friend class folly::LockedPtrBase; friend class folly::LockedPtrBase;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment