Commit 3af92dbe authored by Aaryaman Sagar's avatar Aaryaman Sagar Committed by Facebook Github Bot

Remove Synchronized::asConst

Summary: `folly::as_const` instead

Reviewed By: yfeldblum

Differential Revision: D8248219

fbshipit-source-id: 22853d86c93065ee584458f18b7cd0e8d528d2f0
parent fa32adfe
...@@ -738,19 +738,6 @@ struct Synchronized : public SynchronizedBase< ...@@ -738,19 +738,6 @@ struct Synchronized : public SynchronizedBase<
return ConstLockedPtr(this, std::chrono::milliseconds(milliseconds)); return ConstLockedPtr(this, std::chrono::milliseconds(milliseconds));
} }
/**
* Sometimes, although you have a mutable object, you only want to
* call a const method against it. The most efficient way to achieve
* that is by using a read lock. You get to do so by using
* obj.asConst()->method() instead of obj->method().
*
* NOTE: This API is planned to be deprecated in an upcoming diff.
* Use rlock() instead.
*/
const Synchronized& asConst() const {
return *this;
}
/** /**
* Swaps with another Synchronized. Protected against * Swaps with another Synchronized. Protected against
* self-swap. Only data is swapped. Locks are acquired in increasing * self-swap. Only data is swapped. Locks are acquired in increasing
...@@ -1781,7 +1768,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) { ...@@ -1781,7 +1768,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
#define SYNCHRONIZED_CONST(...) \ #define SYNCHRONIZED_CONST(...) \
SYNCHRONIZED( \ SYNCHRONIZED( \
FB_VA_GLUE(FB_ARG_1, (__VA_ARGS__)), \ FB_VA_GLUE(FB_ARG_1, (__VA_ARGS__)), \
(FB_VA_GLUE(FB_ARG_2_OR_1, (__VA_ARGS__))).asConst()) as_const(FB_VA_GLUE(FB_ARG_2_OR_1, (__VA_ARGS__))))
/** /**
* Similar to TIMED_SYNCHRONIZED, but only uses a read lock. * Similar to TIMED_SYNCHRONIZED, but only uses a read lock.
...@@ -1790,7 +1777,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) { ...@@ -1790,7 +1777,7 @@ void swap(Synchronized<T, M>& lhs, Synchronized<T, M>& rhs) {
TIMED_SYNCHRONIZED( \ TIMED_SYNCHRONIZED( \
timeout, \ timeout, \
FB_VA_GLUE(FB_ARG_1, (__VA_ARGS__)), \ FB_VA_GLUE(FB_ARG_1, (__VA_ARGS__)), \
(FB_VA_GLUE(FB_ARG_2_OR_1, (__VA_ARGS__))).asConst()) as_const(FB_VA_GLUE(FB_ARG_2_OR_1, (__VA_ARGS__))))
/** /**
* Synchronizes two Synchronized objects (they may encapsulate * Synchronizes two Synchronized objects (they may encapsulate
......
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