Commit 87520af5 authored by Adam Simpkins's avatar Adam Simpkins Committed by JoelMarcey

update call sites to use SpinLock

Summary:
Update call sites to use the new folly::SpinLock name, instead of
folly::io::PortableSpinLock.

Test Plan: Built and ran the folly unit tests.

Reviewed By: davejwatson@fb.com

Subscribers: doug, net-systems@, exa, folly-diffs@

FB internal diff: D1734647

Signature: t1:1734647:1418334925:1bbcffccd06907224de2a102f8d4bfbe1bd62fd1
parent 4494e275
...@@ -33,9 +33,9 @@ ...@@ -33,9 +33,9 @@
#include <folly/Bits.h> #include <folly/Bits.h>
#include <folly/SocketAddress.h> #include <folly/SocketAddress.h>
#include <folly/SpinLock.h>
#include <folly/io/IOBuf.h> #include <folly/io/IOBuf.h>
#include <folly/io/Cursor.h> #include <folly/io/Cursor.h>
#include <folly/io/PortableSpinLock.h>
using folly::SocketAddress; using folly::SocketAddress;
using folly::SSLContext; using folly::SSLContext;
...@@ -44,9 +44,9 @@ using std::shared_ptr; ...@@ -44,9 +44,9 @@ using std::shared_ptr;
using folly::Endian; using folly::Endian;
using folly::IOBuf; using folly::IOBuf;
using folly::SpinLock;
using folly::SpinLockGuard;
using folly::io::Cursor; using folly::io::Cursor;
using folly::io::PortableSpinLock;
using folly::io::PortableSpinLockGuard;
using std::unique_ptr; using std::unique_ptr;
using std::bind; using std::bind;
...@@ -62,7 +62,7 @@ size_t MIN_WRITE_SIZE = 1500; ...@@ -62,7 +62,7 @@ size_t MIN_WRITE_SIZE = 1500;
// We have one single dummy SSL context so that we can implement attach // We have one single dummy SSL context so that we can implement attach
// and detach methods in a thread safe fashion without modifying opnessl. // and detach methods in a thread safe fashion without modifying opnessl.
static SSLContext *dummyCtx = nullptr; static SSLContext *dummyCtx = nullptr;
static PortableSpinLock dummyCtxLock; static SpinLock dummyCtxLock;
// Numbers chosen as to not collide with functions in ssl.h // Numbers chosen as to not collide with functions in ssl.h
const uint8_t TASYNCSSLSOCKET_F_PERFORM_READ = 90; const uint8_t TASYNCSSLSOCKET_F_PERFORM_READ = 90;
...@@ -494,7 +494,7 @@ void AsyncSSLSocket::attachSSLContext( ...@@ -494,7 +494,7 @@ void AsyncSSLSocket::attachSSLContext(
// In order to call attachSSLContext, detachSSLContext must have been // In order to call attachSSLContext, detachSSLContext must have been
// previously called which sets the socket's context to the dummy // previously called which sets the socket's context to the dummy
// context. Thus we must acquire this lock. // context. Thus we must acquire this lock.
PortableSpinLockGuard guard(dummyCtxLock); SpinLockGuard guard(dummyCtxLock);
SSL_set_SSL_CTX(ssl_, ctx->getSSLCtx()); SSL_set_SSL_CTX(ssl_, ctx->getSSLCtx());
} }
...@@ -509,7 +509,7 @@ void AsyncSSLSocket::detachSSLContext() { ...@@ -509,7 +509,7 @@ void AsyncSSLSocket::detachSSLContext() {
ssl_->initial_ctx = nullptr; ssl_->initial_ctx = nullptr;
} }
#endif #endif
PortableSpinLockGuard guard(dummyCtxLock); SpinLockGuard guard(dummyCtxLock);
if (nullptr == dummyCtx) { if (nullptr == dummyCtx) {
// We need to lazily initialize the dummy context so we don't // We need to lazily initialize the dummy context so we don't
// accidentally override any programmatic settings to openssl // accidentally override any programmatic settings to openssl
......
...@@ -19,12 +19,12 @@ ...@@ -19,12 +19,12 @@
#include <fcntl.h> #include <fcntl.h>
#include <unistd.h> #include <unistd.h>
#include <folly/io/PortableSpinLock.h>
#include <folly/io/async/EventBase.h> #include <folly/io/async/EventBase.h>
#include <folly/io/async/EventHandler.h> #include <folly/io/async/EventHandler.h>
#include <folly/io/async/Request.h> #include <folly/io/async/Request.h>
#include <folly/Likely.h> #include <folly/Likely.h>
#include <folly/ScopeGuard.h> #include <folly/ScopeGuard.h>
#include <folly/SpinLock.h>
#include <glog/logging.h> #include <glog/logging.h>
#include <deque> #include <deque>
...@@ -379,7 +379,7 @@ class NotificationQueue { ...@@ -379,7 +379,7 @@ class NotificationQueue {
try { try {
folly::io::PortableSpinLockGuard g(spinlock_); folly::SpinLockGuard g(spinlock_);
if (UNLIKELY(queue_.empty())) { if (UNLIKELY(queue_.empty())) {
return false; return false;
...@@ -403,7 +403,7 @@ class NotificationQueue { ...@@ -403,7 +403,7 @@ class NotificationQueue {
} }
int size() { int size() {
folly::io::PortableSpinLockGuard g(spinlock_); folly::SpinLockGuard g(spinlock_);
return queue_.size(); return queue_.size();
} }
...@@ -505,7 +505,7 @@ class NotificationQueue { ...@@ -505,7 +505,7 @@ class NotificationQueue {
checkPid(); checkPid();
bool signal = false; bool signal = false;
{ {
folly::io::PortableSpinLockGuard g(spinlock_); folly::SpinLockGuard g(spinlock_);
if (checkDraining(throws) || !checkQueueSize(maxSize, throws)) { if (checkDraining(throws) || !checkQueueSize(maxSize, throws)) {
return false; return false;
} }
...@@ -529,7 +529,7 @@ class NotificationQueue { ...@@ -529,7 +529,7 @@ class NotificationQueue {
checkPid(); checkPid();
bool signal = false; bool signal = false;
{ {
folly::io::PortableSpinLockGuard g(spinlock_); folly::SpinLockGuard g(spinlock_);
if (checkDraining(throws) || !checkQueueSize(maxSize, throws)) { if (checkDraining(throws) || !checkQueueSize(maxSize, throws)) {
return false; return false;
} }
...@@ -551,7 +551,7 @@ class NotificationQueue { ...@@ -551,7 +551,7 @@ class NotificationQueue {
bool signal = false; bool signal = false;
size_t numAdded = 0; size_t numAdded = 0;
{ {
folly::io::PortableSpinLockGuard g(spinlock_); folly::SpinLockGuard g(spinlock_);
checkDraining(); checkDraining();
while (first != last) { while (first != last) {
queue_.push_back(std::make_pair(*first, RequestContext::saveContext())); queue_.push_back(std::make_pair(*first, RequestContext::saveContext()));
...@@ -567,7 +567,7 @@ class NotificationQueue { ...@@ -567,7 +567,7 @@ class NotificationQueue {
} }
} }
mutable folly::io::PortableSpinLock spinlock_; mutable folly::SpinLock spinlock_;
int eventfd_; int eventfd_;
int pipeFds_[2]; // to fallback to on older/non-linux systems int pipeFds_[2]; // to fallback to on older/non-linux systems
uint32_t advisoryMaxQueueSize_; uint32_t advisoryMaxQueueSize_;
...@@ -730,7 +730,7 @@ void NotificationQueue<MessageT>::Consumer::init( ...@@ -730,7 +730,7 @@ void NotificationQueue<MessageT>::Consumer::init(
queue_ = queue; queue_ = queue;
{ {
folly::io::PortableSpinLockGuard g(queue_->spinlock_); folly::SpinLockGuard g(queue_->spinlock_);
queue_->numConsumers_++; queue_->numConsumers_++;
} }
queue_->signalEvent(); queue_->signalEvent();
...@@ -750,7 +750,7 @@ void NotificationQueue<MessageT>::Consumer::stopConsuming() { ...@@ -750,7 +750,7 @@ void NotificationQueue<MessageT>::Consumer::stopConsuming() {
} }
{ {
folly::io::PortableSpinLockGuard g(queue_->spinlock_); folly::SpinLockGuard g(queue_->spinlock_);
queue_->numConsumers_--; queue_->numConsumers_--;
setActive(false); setActive(false);
} }
...@@ -764,7 +764,7 @@ void NotificationQueue<MessageT>::Consumer::stopConsuming() { ...@@ -764,7 +764,7 @@ void NotificationQueue<MessageT>::Consumer::stopConsuming() {
template<typename MessageT> template<typename MessageT>
bool NotificationQueue<MessageT>::Consumer::consumeUntilDrained() noexcept { bool NotificationQueue<MessageT>::Consumer::consumeUntilDrained() noexcept {
{ {
folly::io::PortableSpinLockGuard g(queue_->spinlock_); folly::SpinLockGuard g(queue_->spinlock_);
if (queue_->draining_) { if (queue_->draining_) {
return false; return false;
} }
...@@ -772,7 +772,7 @@ bool NotificationQueue<MessageT>::Consumer::consumeUntilDrained() noexcept { ...@@ -772,7 +772,7 @@ bool NotificationQueue<MessageT>::Consumer::consumeUntilDrained() noexcept {
} }
consumeMessages(true); consumeMessages(true);
{ {
folly::io::PortableSpinLockGuard g(queue_->spinlock_); folly::SpinLockGuard g(queue_->spinlock_);
queue_->draining_ = false; queue_->draining_ = false;
} }
return true; return true;
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
#include <openssl/x509v3.h> #include <openssl/x509v3.h>
#include <folly/Format.h> #include <folly/Format.h>
#include <folly/io/PortableSpinLock.h> #include <folly/SpinLock.h>
// --------------------------------------------------------------------- // ---------------------------------------------------------------------
// SSLContext implementation // SSLContext implementation
...@@ -534,7 +534,7 @@ struct SSLLock { ...@@ -534,7 +534,7 @@ struct SSLLock {
} }
SSLContext::SSLLockType lockType; SSLContext::SSLLockType lockType;
folly::io::PortableSpinLock spinLock{}; folly::SpinLock spinLock{};
std::mutex mutex; std::mutex mutex;
}; };
......
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