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

refactor: rewrite RWLock implementation with TVar (closes #157) #158

Merged
merged 2 commits into from
Sep 11, 2020

Conversation

nbacquey
Copy link
Member

No description provided.

Copy link
Member

@facundominguez facundominguez left a comment

Choose a reason for hiding this comment

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

Looks great!

@nbacquey nbacquey merged commit 42af35d into master Sep 11, 2020
@nbacquey nbacquey deleted the rwlock-refactor branch September 11, 2020 16:35
((readers, Writing mv), when (readers > 0) (takeMVar mv))
atomically $ modifyTVar' ref $ \(readers, _) -> (readers, Writing)
atomically $ readTVar ref >>= \case
(0, _) -> return ()
Copy link
Member

Choose a reason for hiding this comment

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

One minor difference here is that the writer will be woken up whenever a read lock is released, whereas before it would be woken up only when no readers are left.

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.

2 participants