-
Notifications
You must be signed in to change notification settings - Fork 13.4k
add rust_trylock_little_lock #10428
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 rust_trylock_little_lock #10428
Conversation
_holding_thread = pthread_self(); | ||
#endif | ||
return true; | ||
} else if (trylock == EBUSY) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
How come this is explicitly checked?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
EBUSY is what happens when the lock is already locked.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hm, I'd be more comfortable with a comment along the lines of:
// Explicitly return false on EBUSY (lock is already locked), but assert on all other errors
I've attempted to improve the readability. |
I've fixed the compile error. I'm not able to compile and test this locally, which is why this happened. The error I get has something to do with stage0 snapshot not containing my changes to the C++ lib. I might have to split this into two changes. One to change the C++ lib and a later change to libstd? |
Oh I forgot to ask before, but could you expand the commit message a little bit? Just the standard short-title + 1-2 sentences after it explaining what's going on. Thanks! |
@huonw Thanks, adding
This was rebased off latest master. @alexcrichton I updated the commit message, but before this is merged I'll probably need to rebase off master once the above issue is fixed. |
This doesn't look to be a snapshot problem, we rebuild the runtime for stage0. It looks like you're just missing the shim C function in the middle. |
Sorry, two different problems. First I had a problem building stage0, which iirc was complaining about librustrt not containing rust_trylock_littlelock. This was related to my change and was fixed by the annotation suggested by huonw. Then I pulled in the latest master changes and like I said above, got a new error while running make check. This second error seems unrelated to my changes it just means my pull request won't build because I pulled in someone else's bug in librustpkg. |
Looks like 65aacd0#diff-e16b4a8a6901a9937ee5627cfddb3590R474 fixes my second problem. I'll pull that in and try again tomorrow. |
This should be good to merge now. I rebased off current master and it passed |
Are you sure? I'm still not seeing a definition of |
You're right, it would help if I committed my local changes. |
Try to acquire lock and succeed only if lock is not already held. Uses TryEnterCriticalSection or pthread_mutex_trylock.
I need try_lock for an algorithm I'm trying to implement in Rust.
I need try_lock for an algorithm I'm trying to implement in Rust.