From 87520af5728b634c6b8b51dfe54508e5166e1575 Mon Sep 17 00:00:00 2001 From: Adam Simpkins Date: Thu, 11 Dec 2014 13:23:05 -0800 Subject: [PATCH] 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 --- folly/io/async/AsyncSSLSocket.cpp | 12 ++++++------ folly/io/async/NotificationQueue.h | 22 +++++++++++----------- folly/io/async/SSLContext.cpp | 4 ++-- 3 files changed, 19 insertions(+), 19 deletions(-) diff --git a/folly/io/async/AsyncSSLSocket.cpp b/folly/io/async/AsyncSSLSocket.cpp index 69efb113..fd1d9a9e 100644 --- a/folly/io/async/AsyncSSLSocket.cpp +++ b/folly/io/async/AsyncSSLSocket.cpp @@ -33,9 +33,9 @@ #include #include +#include #include #include -#include using folly::SocketAddress; using folly::SSLContext; @@ -44,9 +44,9 @@ using std::shared_ptr; using folly::Endian; using folly::IOBuf; +using folly::SpinLock; +using folly::SpinLockGuard; using folly::io::Cursor; -using folly::io::PortableSpinLock; -using folly::io::PortableSpinLockGuard; using std::unique_ptr; using std::bind; @@ -62,7 +62,7 @@ size_t MIN_WRITE_SIZE = 1500; // We have one single dummy SSL context so that we can implement attach // and detach methods in a thread safe fashion without modifying opnessl. static SSLContext *dummyCtx = nullptr; -static PortableSpinLock dummyCtxLock; +static SpinLock dummyCtxLock; // Numbers chosen as to not collide with functions in ssl.h const uint8_t TASYNCSSLSOCKET_F_PERFORM_READ = 90; @@ -494,7 +494,7 @@ void AsyncSSLSocket::attachSSLContext( // In order to call attachSSLContext, detachSSLContext must have been // previously called which sets the socket's context to the dummy // context. Thus we must acquire this lock. - PortableSpinLockGuard guard(dummyCtxLock); + SpinLockGuard guard(dummyCtxLock); SSL_set_SSL_CTX(ssl_, ctx->getSSLCtx()); } @@ -509,7 +509,7 @@ void AsyncSSLSocket::detachSSLContext() { ssl_->initial_ctx = nullptr; } #endif - PortableSpinLockGuard guard(dummyCtxLock); + SpinLockGuard guard(dummyCtxLock); if (nullptr == dummyCtx) { // We need to lazily initialize the dummy context so we don't // accidentally override any programmatic settings to openssl diff --git a/folly/io/async/NotificationQueue.h b/folly/io/async/NotificationQueue.h index 317a73ff..83a23722 100644 --- a/folly/io/async/NotificationQueue.h +++ b/folly/io/async/NotificationQueue.h @@ -19,12 +19,12 @@ #include #include -#include #include #include #include #include #include +#include #include #include @@ -379,7 +379,7 @@ class NotificationQueue { try { - folly::io::PortableSpinLockGuard g(spinlock_); + folly::SpinLockGuard g(spinlock_); if (UNLIKELY(queue_.empty())) { return false; @@ -403,7 +403,7 @@ class NotificationQueue { } int size() { - folly::io::PortableSpinLockGuard g(spinlock_); + folly::SpinLockGuard g(spinlock_); return queue_.size(); } @@ -505,7 +505,7 @@ class NotificationQueue { checkPid(); bool signal = false; { - folly::io::PortableSpinLockGuard g(spinlock_); + folly::SpinLockGuard g(spinlock_); if (checkDraining(throws) || !checkQueueSize(maxSize, throws)) { return false; } @@ -529,7 +529,7 @@ class NotificationQueue { checkPid(); bool signal = false; { - folly::io::PortableSpinLockGuard g(spinlock_); + folly::SpinLockGuard g(spinlock_); if (checkDraining(throws) || !checkQueueSize(maxSize, throws)) { return false; } @@ -551,7 +551,7 @@ class NotificationQueue { bool signal = false; size_t numAdded = 0; { - folly::io::PortableSpinLockGuard g(spinlock_); + folly::SpinLockGuard g(spinlock_); checkDraining(); while (first != last) { queue_.push_back(std::make_pair(*first, RequestContext::saveContext())); @@ -567,7 +567,7 @@ class NotificationQueue { } } - mutable folly::io::PortableSpinLock spinlock_; + mutable folly::SpinLock spinlock_; int eventfd_; int pipeFds_[2]; // to fallback to on older/non-linux systems uint32_t advisoryMaxQueueSize_; @@ -730,7 +730,7 @@ void NotificationQueue::Consumer::init( queue_ = queue; { - folly::io::PortableSpinLockGuard g(queue_->spinlock_); + folly::SpinLockGuard g(queue_->spinlock_); queue_->numConsumers_++; } queue_->signalEvent(); @@ -750,7 +750,7 @@ void NotificationQueue::Consumer::stopConsuming() { } { - folly::io::PortableSpinLockGuard g(queue_->spinlock_); + folly::SpinLockGuard g(queue_->spinlock_); queue_->numConsumers_--; setActive(false); } @@ -764,7 +764,7 @@ void NotificationQueue::Consumer::stopConsuming() { template bool NotificationQueue::Consumer::consumeUntilDrained() noexcept { { - folly::io::PortableSpinLockGuard g(queue_->spinlock_); + folly::SpinLockGuard g(queue_->spinlock_); if (queue_->draining_) { return false; } @@ -772,7 +772,7 @@ bool NotificationQueue::Consumer::consumeUntilDrained() noexcept { } consumeMessages(true); { - folly::io::PortableSpinLockGuard g(queue_->spinlock_); + folly::SpinLockGuard g(queue_->spinlock_); queue_->draining_ = false; } return true; diff --git a/folly/io/async/SSLContext.cpp b/folly/io/async/SSLContext.cpp index 80d414b0..02eba8f8 100644 --- a/folly/io/async/SSLContext.cpp +++ b/folly/io/async/SSLContext.cpp @@ -22,7 +22,7 @@ #include #include -#include +#include // --------------------------------------------------------------------- // SSLContext implementation @@ -534,7 +534,7 @@ struct SSLLock { } SSLContext::SSLLockType lockType; - folly::io::PortableSpinLock spinLock{}; + folly::SpinLock spinLock{}; std::mutex mutex; }; -- 2.34.1