This is an automated email from the ASF dual-hosted git repository.
masaori pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/trafficserver.git
The following commit(s) were added to refs/heads/master by this push:
new c58b0db41d Use BRAVO rwlock for ReplaceablePtr (#11786)
c58b0db41d is described below
commit c58b0db41d61f372fb975e06d1c76550a7eaba92
Author: Masaori Koshiba <[email protected]>
AuthorDate: Wed Oct 2 08:00:10 2024 +0900
Use BRAVO rwlock for ReplaceablePtr (#11786)
---
src/iocore/cache/P_CacheHosting.h | 11 +++++++----
1 file changed, 7 insertions(+), 4 deletions(-)
diff --git a/src/iocore/cache/P_CacheHosting.h
b/src/iocore/cache/P_CacheHosting.h
index 1802ba7665..9e83e09db4 100644
--- a/src/iocore/cache/P_CacheHosting.h
+++ b/src/iocore/cache/P_CacheHosting.h
@@ -28,6 +28,8 @@
#include "tscore/MatcherUtils.h"
#include "tscore/HostLookup.h"
+#include "tsutil/Bravo.h"
+
#define CACHE_MEM_FREE_TIMEOUT HRTIME_SECONDS(1)
class StripeSM;
@@ -148,8 +150,8 @@ public:
class ScopedReader
{
public:
- ScopedReader(ReplaceablePtr<T> *ptr) : ptr(ptr) { ptr->m.lock_shared(); }
- ~ScopedReader() { ptr->m.unlock_shared(); }
+ ScopedReader(ReplaceablePtr<T> *ptr) : ptr(ptr) {
ptr->m.lock_shared(_token); }
+ ~ScopedReader() { ptr->m.unlock_shared(_token); }
const T *
operator->()
@@ -168,6 +170,7 @@ public:
ScopedReader &operator=(const ScopedReader &) = delete;
ReplaceablePtr<T> *ptr;
+ ts::bravo::Token _token = 0;
};
// ScopedWriter constructs an object which is allowed to read and modify the
@@ -206,8 +209,8 @@ private:
ReplaceablePtr(const ReplaceablePtr &) = delete;
ReplaceablePtr &operator=(const ReplaceablePtr &) = delete;
- std::unique_ptr<T> h = nullptr;
- std::shared_mutex m;
+ std::unique_ptr<T> h = nullptr;
+ ts::bravo::shared_mutex m;
friend class ReplaceablePtr::ScopedReader;
};