Commit d418b5ee authored by Yedidya Feldblum's avatar Yedidya Feldblum Committed by Facebook GitHub Bot

check functions for DistributedMutex

Summary: To observe how the compiler generates corresponding code.

Reviewed By: Alfus

Differential Revision: D28984027

fbshipit-source-id: d1c86197931aad257eb922cec9810c71ecdfc20a
parent 348568d4
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
#include <folly/container/Array.h> #include <folly/container/Array.h>
#include <folly/container/Foreach.h> #include <folly/container/Foreach.h>
#include <folly/lang/CustomizationPoint.h> #include <folly/lang/CustomizationPoint.h>
#include <folly/lang/Keep.h>
#include <folly/portability/GTest.h> #include <folly/portability/GTest.h>
#include <folly/synchronization/Baton.h> #include <folly/synchronization/Baton.h>
#include <folly/test/DeterministicSchedule.h> #include <folly/test/DeterministicSchedule.h>
...@@ -32,6 +33,63 @@ ...@@ -32,6 +33,63 @@
using namespace std::literals; using namespace std::literals;
extern "C" FOLLY_KEEP void //
check_unique_lock_distributed_mutex_lock(
std::unique_lock<folly::DistributedMutex>& lock) {
lock.lock();
}
extern "C" FOLLY_KEEP bool //
check_unique_lock_distributed_mutex_try_lock(
std::unique_lock<folly::DistributedMutex>& lock) {
return lock.try_lock();
}
extern "C" FOLLY_KEEP bool //
check_unique_lock_distributed_mutex_try_lock_for_ns(
std::unique_lock<folly::DistributedMutex>& lock,
std::chrono::nanoseconds timeout) {
return lock.try_lock_for(timeout);
}
extern "C" FOLLY_KEEP bool //
check_unique_lock_distributed_mutex_try_lock_until_steady_clock_time_point(
std::unique_lock<folly::DistributedMutex>& lock,
std::chrono::steady_clock::time_point deadline) {
return lock.try_lock_until(deadline);
}
extern "C" FOLLY_KEEP void //
check_unique_lock_distributed_mutex_unlock(
std::unique_lock<folly::DistributedMutex>& lock) {
lock.unlock();
}
extern "C" FOLLY_KEEP void //
check_unique_lock_distributed_mutex_raii_lock( //
folly::DistributedMutex& mutex) {
std::unique_lock lock{mutex};
folly::detail::keep_sink_nx();
}
extern "C" FOLLY_KEEP void //
check_unique_lock_distributed_mutex_raii_try_lock(
folly::DistributedMutex& mutex) {
if (std::unique_lock lock{mutex, std::try_to_lock}) {
folly::detail::keep_sink_nx();
}
}
extern "C" FOLLY_KEEP void //
check_unique_lock_distributed_mutex_raii_try_lock_for_ns(
folly::DistributedMutex& mutex, //
std::chrono::nanoseconds timeout) {
if (std::unique_lock lock{mutex, timeout}) {
folly::detail::keep_sink_nx();
}
}
extern "C" FOLLY_KEEP void //
check_unique_lock_distributed_mutex_raii_try_lock_until_steady_clock_time_point(
folly::DistributedMutex& mutex,
std::chrono::steady_clock::time_point deadline) {
if (std::unique_lock lock{mutex, deadline}) {
folly::detail::keep_sink_nx();
}
}
namespace folly { namespace folly {
namespace test { namespace test {
/** /**
......
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