Skip to content

Commit

Permalink
cut unused folly::ssl::LockType::SHAREDMUTEX
Browse files Browse the repository at this point in the history
Reviewed By: ot

Differential Revision: D51311814

fbshipit-source-id: c2aedf9d1f187976d612a502eadef0d112f2f45c
  • Loading branch information
yfeldblum authored and facebook-github-bot committed Nov 15, 2023
1 parent 8ad7182 commit baacbbd
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 17 deletions.
2 changes: 1 addition & 1 deletion folly/ssl/OpenSSLLockTypes.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
namespace folly {
namespace ssl {

enum class LockType { MUTEX, SPINLOCK, SHAREDMUTEX, NONE };
enum class LockType { MUTEX, SPINLOCK, NONE };

/**
* Map between an OpenSSL lock (see constants in crypto/crypto.h) and the
Expand Down
18 changes: 2 additions & 16 deletions folly/ssl/detail/OpenSSLThreading.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#include <glog/logging.h>

#include <folly/Portability.h>
#include <folly/SharedMutex.h>
#include <folly/SpinLock.h>

// We cannot directly use portability/openssl because it also depends on us.
Expand Down Expand Up @@ -76,40 +75,27 @@ struct SSLLock {
FOLLY_MAYBE_UNUSED explicit SSLLock(LockType inLockType = LockType::MUTEX)
: lockType(inLockType) {}

FOLLY_MAYBE_UNUSED void lock(bool read) {
FOLLY_MAYBE_UNUSED void lock(bool /* read */) {
if (lockType == LockType::MUTEX) {
mutex.lock();
} else if (lockType == LockType::SPINLOCK) {
spinLock.lock();
} else if (lockType == LockType::SHAREDMUTEX) {
if (read) {
sharedMutex.lock_shared();
} else {
sharedMutex.lock();
}
}
// lockType == LOCK_NONE, no-op
}

FOLLY_MAYBE_UNUSED void unlock(bool read) {
FOLLY_MAYBE_UNUSED void unlock(bool /* read */) {
if (lockType == LockType::MUTEX) {
mutex.unlock();
} else if (lockType == LockType::SPINLOCK) {
spinLock.unlock();
} else if (lockType == LockType::SHAREDMUTEX) {
if (read) {
sharedMutex.unlock_shared();
} else {
sharedMutex.unlock();
}
}
// lockType == LOCK_NONE, no-op
}

LockType lockType;
folly::SpinLock spinLock{};
std::mutex mutex;
SharedMutex sharedMutex;
};
} // namespace

Expand Down

0 comments on commit baacbbd

Please sign in to comment.