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

(Docs) Fix MLock constructor to not hang on first call to 'acquire' #597

Merged
merged 1 commit into from
Aug 1, 2019

Conversation

sloshy
Copy link

@sloshy sloshy commented Aug 1, 2019

I think a coworker of mine found a bug in one of the MVar examples. https://typelevel.org/cats-effect/concurrency/mvar.html#use-case-asynchronous-lock-binary-semaphore-mutex

When you make a new MLock, it isn't initialized, so if you call acquire you will just be waiting forever. It basically starts in an already pre-acquired state which might be confusing. I replaced the MVar[IO].empty[Unit] call with a call to MVar[IO].of(()) which should work.

@djspiewak djspiewak merged commit 5338529 into typelevel:master Aug 1, 2019
@codecov-io
Copy link

Codecov Report

Merging #597 into master will decrease coverage by 0.23%.
The diff coverage is n/a.

@@            Coverage Diff             @@
##           master     #597      +/-   ##
==========================================
- Coverage   89.22%   88.99%   -0.24%     
==========================================
  Files          68       68              
  Lines        2144     2144              
  Branches      108      108              
==========================================
- Hits         1913     1908       -5     
- Misses        231      236       +5

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.

3 participants