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

Prefer invoke_result_t in DistributedMutex

Summary: [Folly] Prefer `invoke_result_t` in `DistributedMutex` over the underlying `decltype` and `declval` implementation.

Reviewed By: aary

Differential Revision: D19321643

fbshipit-source-id: 323a0fce49447d2f009ad3bc61e285de3f311ff1
parent 59e20c74
...@@ -1098,8 +1098,8 @@ DistributedMutex<Atomic, TimePublishing>::lock() { ...@@ -1098,8 +1098,8 @@ DistributedMutex<Atomic, TimePublishing>::lock() {
} }
template <template <typename> class Atomic, bool TimePublishing> template <template <typename> class Atomic, bool TimePublishing>
template <typename Rep, typename Period, typename Func, typename ReturnType> template <typename Rep, typename Period, typename Func>
folly::Optional<ReturnType> folly::Optional<invoke_result_t<Func&>>
DistributedMutex<Atomic, TimePublishing>::try_lock_combine_for( DistributedMutex<Atomic, TimePublishing>::try_lock_combine_for(
const std::chrono::duration<Rep, Period>& duration, const std::chrono::duration<Rep, Period>& duration,
Func func) { Func func) {
...@@ -1115,8 +1115,8 @@ DistributedMutex<Atomic, TimePublishing>::try_lock_combine_for( ...@@ -1115,8 +1115,8 @@ DistributedMutex<Atomic, TimePublishing>::try_lock_combine_for(
} }
template <template <typename> class Atomic, bool TimePublishing> template <template <typename> class Atomic, bool TimePublishing>
template <typename Clock, typename Duration, typename Func, typename ReturnType> template <typename Clock, typename Duration, typename Func>
folly::Optional<ReturnType> folly::Optional<invoke_result_t<Func&>>
DistributedMutex<Atomic, TimePublishing>::try_lock_combine_until( DistributedMutex<Atomic, TimePublishing>::try_lock_combine_until(
const std::chrono::time_point<Clock, Duration>& deadline, const std::chrono::time_point<Clock, Duration>& deadline,
Func func) { Func func) {
......
...@@ -309,12 +309,8 @@ class DistributedMutex { ...@@ -309,12 +309,8 @@ class DistributedMutex {
* characteristics as the non-timed version of the combine method. If * characteristics as the non-timed version of the combine method. If
* performance is critical, use that one instead * performance is critical, use that one instead
*/ */
template < template <typename Rep, typename Period, typename Task>
typename Rep, folly::Optional<invoke_result_t<Task&>> try_lock_combine_for(
typename Period,
typename Task,
typename ReturnType = decltype(std::declval<Task&>()())>
folly::Optional<ReturnType> try_lock_combine_for(
const std::chrono::duration<Rep, Period>& duration, const std::chrono::duration<Rep, Period>& duration,
Task task); Task task);
...@@ -324,12 +320,8 @@ class DistributedMutex { ...@@ -324,12 +320,8 @@ class DistributedMutex {
* Other than the difference in the meaning of the second argument, the * Other than the difference in the meaning of the second argument, the
* semantics of this function are identical to try_lock_combine_for() * semantics of this function are identical to try_lock_combine_for()
*/ */
template < template <typename Clock, typename Duration, typename Task>
typename Clock, folly::Optional<invoke_result_t<Task&>> try_lock_combine_until(
typename Duration,
typename Task,
typename ReturnType = decltype(std::declval<Task&>()())>
folly::Optional<ReturnType> try_lock_combine_until(
const std::chrono::time_point<Clock, Duration>& deadline, const std::chrono::time_point<Clock, Duration>& deadline,
Task task); Task task);
......
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