Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add on-the-fly mutexes by key #322

Merged
merged 4 commits into from
Sep 25, 2024
Merged

add on-the-fly mutexes by key #322

merged 4 commits into from
Sep 25, 2024

Conversation

AdoAdoAdo
Copy link
Contributor

No description provided.

@AdoAdoAdo AdoAdoAdo changed the base branch from main to feat/header-proof September 18, 2024 11:31
@AdoAdoAdo AdoAdoAdo marked this pull request as ready for review September 18, 2024 11:31

// Unlock unlocks the Mutex for the given key
func (km *keyRWMutex) Unlock(key string) {
km.getForUnlock(key).unlock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not found, nil will be returned and it will panic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created on getForUnlock if not existing, so that it panics because of an Unlock on an unlocked mutex instead of dereferencing a nil pointer.


// RUnlock unlocks for read the Mutex for the given key
func (km *keyRWMutex) RUnlock(key string) {
km.getForRUnlock(key).rUnlock()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if not found (or two unlocks), nil will be returned and it will panic

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

created on getForRUnlock if not existing, so that it panics because of an RUnlock on an unlocked mutex instead of dereferencing a nil pointer.

@AdoAdoAdo AdoAdoAdo merged commit 120b0b6 into feat/header-proof Sep 25, 2024
2 checks passed
@AdoAdoAdo AdoAdoAdo deleted the mutex-by-key branch September 25, 2024 11:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants