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

Example on Threads in README results in deadlocks #152

Closed
OkonSamuel opened this issue Apr 26, 2020 · 4 comments · Fixed by #153
Closed

Example on Threads in README results in deadlocks #152

OkonSamuel opened this issue Apr 26, 2020 · 4 comments · Fixed by #153

Comments

@OkonSamuel
Copy link

The following example from README results in hanging for n>=70 using 4 Threads

n = 10
p = Progress(n)
tasks = Vector{Task}(undef, n)
for i in 1:n
    tasks[i] = Threads.@spawn begin
        sleep(2*rand())
        next!(p)
    end
end
wait.(tasks)
@IanButterworth
Copy link
Collaborator

I can't replicate this locally, but it might be that we should be using ReentrantLock over SpinLock. I've heard mentions that ReentrantLocks should basically always be used over SpinLocks since we added this functionality.

@OkonSamuel can you try out #153 and see if that fixes it for you?

@OkonSamuel
Copy link
Author

@ianshmean Thanks. I'll check it out

@OkonSamuel
Copy link
Author

OkonSamuel commented Apr 27, 2020

It now works. Thanks.
PS: Although sometimes the display is distorted and other times its fine.

@IanButterworth
Copy link
Collaborator

Great, I'm going to re-open the issue so that it gets closed when that PR merges

IanButterworth added a commit that referenced this issue May 17, 2020
Minor change given #147
Includes bugfix for #152
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 a pull request may close this issue.

2 participants