Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions re2/dfa.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1152,24 +1152,24 @@ class DFA::RWLocker {
};

DFA::RWLocker::RWLocker(CacheMutex* mu) : mu_(mu), writing_(false) {
mu_->ReaderLock();
mu_->lock_shared();
}

// This function is marked as ABSL_NO_THREAD_SAFETY_ANALYSIS because
// the annotations don't support lock upgrade.
void DFA::RWLocker::LockForWriting() ABSL_NO_THREAD_SAFETY_ANALYSIS {
if (!writing_) {
mu_->ReaderUnlock();
mu_->WriterLock();
mu_->unlock_shared();
mu_->lock();
writing_ = true;
}
}

DFA::RWLocker::~RWLocker() {
if (!writing_)
mu_->ReaderUnlock();
mu_->unlock_shared();
else
mu_->WriterUnlock();
mu_->unlock();
}


Expand Down
4 changes: 2 additions & 2 deletions re2/regexp.cc
Original file line number Diff line number Diff line change
Expand Up @@ -83,8 +83,8 @@ struct RefStorage {
};
alignas(RefStorage) static char ref_storage[sizeof(RefStorage)];

static inline absl::Mutex* ref_mutex() {
return &reinterpret_cast<RefStorage*>(ref_storage)->ref_mutex;
static inline absl::Mutex& ref_mutex() {
return reinterpret_cast<RefStorage*>(ref_storage)->ref_mutex;
}

static inline absl::flat_hash_map<Regexp*, int>* ref_map() {
Expand Down