diff --git a/folly/compression/CompressionContextPool.h b/folly/compression/CompressionContextPool.h index a85d3075299fadf83732c1fc6c17b9dc8e5eefe1..d5862e29d71c0fbb84032bcf2b210bef24064090 100644 --- a/folly/compression/CompressionContextPool.h +++ b/folly/compression/CompressionContextPool.h @@ -78,7 +78,7 @@ class CompressionContextPool { private: void add(InternalRef ptr) { DCHECK(ptr); - stack_->push_back(std::move(ptr)); + stack_.wlock()->push_back(std::move(ptr)); } Creator creator_; diff --git a/folly/executors/GlobalThreadPoolList.cpp b/folly/executors/GlobalThreadPoolList.cpp index 08935750c51a0ea4d59f103149edca2b248dc260..52a409da898dc26816d431d4f10642ce4377a391 100644 --- a/folly/executors/GlobalThreadPoolList.cpp +++ b/folly/executors/GlobalThreadPoolList.cpp @@ -123,12 +123,12 @@ GlobalThreadPoolList& GlobalThreadPoolList::instance() { void GlobalThreadPoolList::registerThreadPool( ThreadPoolListHook* threadPoolId, std::string name) { - globalListImpl_->registerThreadPool(threadPoolId, name); + globalListImpl_.wlock()->registerThreadPool(threadPoolId, name); } void GlobalThreadPoolList::unregisterThreadPool( ThreadPoolListHook* threadPoolId) { - globalListImpl_->unregisterThreadPool(threadPoolId); + globalListImpl_.wlock()->unregisterThreadPool(threadPoolId); } void GlobalThreadPoolList::registerThreadPoolThread( @@ -137,7 +137,7 @@ void GlobalThreadPoolList::registerThreadPoolThread( DCHECK(!threadHook_); threadHook_.reset(make_unique<ThreadListHook>(threadPoolId, threadId)); - globalListImpl_->registerThreadPoolThread(threadPoolId, threadId); + globalListImpl_.wlock()->registerThreadPoolThread(threadPoolId, threadId); } void GlobalThreadPoolList::unregisterThreadPoolThread( @@ -145,7 +145,7 @@ void GlobalThreadPoolList::unregisterThreadPoolThread( std::thread::id threadId) { (void)threadPoolId; (void)threadId; - globalListImpl_->unregisterThreadPoolThread(threadPoolId, threadId); + globalListImpl_.wlock()->unregisterThreadPoolThread(threadPoolId, threadId); } void GlobalThreadPoolListImpl::registerThreadPool( diff --git a/folly/executors/ThreadPoolExecutor.cpp b/folly/executors/ThreadPoolExecutor.cpp index 06fb233ceb15283b952aedae07c094942bc2924f..11939fcf74e04fdc57a266876924a639b9b5467f 100644 --- a/folly/executors/ThreadPoolExecutor.cpp +++ b/folly/executors/ThreadPoolExecutor.cpp @@ -45,7 +45,7 @@ ThreadPoolExecutor::ThreadPoolExecutor( threadPoolHook_("folly::ThreadPoolExecutor"), minThreads_(minThreads), threadTimeout_(FLAGS_threadtimeout_ms) { - getSyncVecThreadPoolExecutors()->push_back(this); + getSyncVecThreadPoolExecutors().wlock()->push_back(this); } ThreadPoolExecutor::~ThreadPoolExecutor() { diff --git a/folly/experimental/coro/SharedMutex.cpp b/folly/experimental/coro/SharedMutex.cpp index 172699390823fab469ada5ed5826205b6bc08841..95562d2c8caec9ce50afe30bc9b903f4e3a5f801 100644 --- a/folly/experimental/coro/SharedMutex.cpp +++ b/folly/experimental/coro/SharedMutex.cpp @@ -23,8 +23,8 @@ using namespace folly::coro; SharedMutexFair::~SharedMutexFair() { - assert(state_->lockedFlagAndReaderCount_ == kUnlocked); - assert(state_->waitersHead_ == nullptr); + assert(state_.lock()->lockedFlagAndReaderCount_ == kUnlocked); + assert(state_.lock()->waitersHead_ == nullptr); } bool SharedMutexFair::try_lock() noexcept { diff --git a/folly/experimental/exception_tracer/ExceptionCounterLib.cpp b/folly/experimental/exception_tracer/ExceptionCounterLib.cpp index a665e247b26e6c0c48962b1a8823c61aaa91a1c7..934ddd7b091c4630ddb01307516f2c6cafd0bb8a 100644 --- a/folly/experimental/exception_tracer/ExceptionCounterLib.cpp +++ b/folly/experimental/exception_tracer/ExceptionCounterLib.cpp @@ -43,7 +43,7 @@ using ExceptionStatsHolderType = struct ExceptionStatsStorage { void appendTo(ExceptionStatsHolderType& data) { ExceptionStatsHolderType tempHolder; - statsHolder->swap(tempHolder); + statsHolder.wlock()->swap(tempHolder); for (const auto& myData : tempHolder) { auto inserted = data.insert(myData); diff --git a/folly/experimental/observer/Observable-inl.h b/folly/experimental/observer/Observable-inl.h index 3fca5fa5a7bf2141b814d26babac00868ed70612..42d3bcf032787b80fcc33f18042ab2e472f6c561 100644 --- a/folly/experimental/observer/Observable-inl.h +++ b/folly/experimental/observer/Observable-inl.h @@ -29,11 +29,11 @@ class ObserverCreatorContext { template <typename... Args> ObserverCreatorContext(Args&&... args) : observable_(std::forward<Args>(args)...) { - state_->updateValue(Traits::get(observable_)); + state_.unsafeGetUnlocked().updateValue(Traits::get(observable_)); } ~ObserverCreatorContext() { - if (state_->value) { + if (state_.unsafeGetUnlocked().value) { Traits::unsubscribe(observable_); } } diff --git a/folly/memory/ThreadCachedArena.cpp b/folly/memory/ThreadCachedArena.cpp index 4034ccf6f75b1dad7698bff8f12fdb85a01278f1..a10f4d8cf94ae5bcbef62fb4571394f92b8f81c0 100644 --- a/folly/memory/ThreadCachedArena.cpp +++ b/folly/memory/ThreadCachedArena.cpp @@ -37,7 +37,7 @@ SysArena* ThreadCachedArena::allocateThreadLocalArena() { } void ThreadCachedArena::zombify(SysArena&& arena) { - zombies_->merge(std::move(arena)); + zombies_.wlock()->merge(std::move(arena)); } size_t ThreadCachedArena::totalSize() const { @@ -45,7 +45,7 @@ size_t ThreadCachedArena::totalSize() const { for (const auto& arena : arena_.accessAllThreads()) { result += arena.totalSize(); } - result += zombies_->totalSize() - sizeof(SysArena); + result += zombies_.rlock()->totalSize() - sizeof(SysArena); return result; } diff --git a/folly/synchronization/detail/ThreadCachedLists.h b/folly/synchronization/detail/ThreadCachedLists.h index 88e5e1f8613fcb9614b119cc69944dabbb954cba..34d3c1411e1f55345afbbea6bfe8f38c984ca448 100644 --- a/folly/synchronization/detail/ThreadCachedLists.h +++ b/folly/synchronization/detail/ThreadCachedLists.h @@ -91,7 +91,7 @@ class ThreadCachedLists : public ThreadCachedListsBase { TLHead(ThreadCachedLists* parent) : parent_(parent) {} ~TLHead() { - parent_->ghead_->splice(*this); + parent_->ghead_.wlock()->splice(*this); } }; diff --git a/folly/test/SynchronizedTestLib-inl.h b/folly/test/SynchronizedTestLib-inl.h index 813d7b771ba2c24e3a437a2a80e10ea97ba413b8..aa9578e21db888a876a63e2b08d2d6f8ccdbf266 100644 --- a/folly/test/SynchronizedTestLib-inl.h +++ b/folly/test/SynchronizedTestLib-inl.h @@ -461,16 +461,16 @@ template <class Mutex> void testDeprecated() { folly::Synchronized<std::vector<int>, Mutex> obj; - obj->resize(1000); + obj.contextualLock()->resize(1000); auto obj2 = obj; - EXPECT_EQ(1000, obj2->size()); + EXPECT_EQ(1000, obj2.contextualLock()->size()); SYNCHRONIZED(obj) { obj.push_back(10); EXPECT_EQ(1001, obj.size()); EXPECT_EQ(10, obj.back()); - EXPECT_EQ(1000, obj2->size()); + EXPECT_EQ(1000, obj2.contextualLock()->size()); } SYNCHRONIZED_CONST(obj) { @@ -481,9 +481,9 @@ void testDeprecated() { lockedObj.front() = 2; } - EXPECT_EQ(1001, obj->size()); - EXPECT_EQ(10, obj->back()); - EXPECT_EQ(1000, obj2->size()); + EXPECT_EQ(1001, obj.contextualLock()->size()); + EXPECT_EQ(10, obj.contextualLock()->back()); + EXPECT_EQ(1000, obj2.contextualLock()->size()); EXPECT_EQ(FB_ARG_2_OR_1(1, 2), 2); EXPECT_EQ(FB_ARG_2_OR_1(1), 1); @@ -767,8 +767,8 @@ void testTimedSynchronized() { folly::Synchronized<uint64_t, Mutex> numTimeouts; auto worker = [&](size_t threadIdx) { - // Test operator-> - v->push_back(2 * threadIdx); + // Test contextualLock() + v.contextualLock()->push_back(2 * threadIdx); // Aaand test the TIMED_SYNCHRONIZED macro for (;;) { @@ -814,8 +814,8 @@ void testTimedSynchronizedWithConst() { folly::Synchronized<uint64_t, Mutex> numTimeouts; auto worker = [&](size_t threadIdx) { - // Test operator-> - v->push_back(threadIdx); + // Test contextualLock() + v.contextualLock()->push_back(threadIdx); // Test TIMED_SYNCHRONIZED_CONST for (;;) {