Skip to content

Conversation

@cheme
Copy link

@cheme cheme commented Jan 12, 2015

I happen to need a sem_getvalue like fn for semaphore, this should do.
With other approach 0 should be return for negative value, which is not really what I needed (see linked code).

@nrc
Copy link
Member

nrc commented Jan 12, 2015

r? @alexcrichton

@alexcrichton
Copy link
Member

I'm somewhat wary about providing this method on semaphores as it's inherently a racy piece of information to inspect about a semaphore. There are perhaps some situations where when you see a particular number you know a particular fact, but in general once you see the value of a semaphore you don't actually know anything for certain.

For example the code snipped in the documentation is racy in that it may not actually unlock the semaphore a correct number of times.

I think for now we may wish to be more conservative about the API.

@cheme
Copy link
Author

cheme commented Jan 13, 2015

Yes, you're right, I think I felt a bit lazy by using a semaphore this way. Guess I'll stick to a condvar + int mutex in my code.

@cheme cheme closed this Jan 13, 2015
lnicola pushed a commit to lnicola/rust that referenced this pull request Nov 19, 2025
…yarn/editors/code/js-yaml-3.14.2

Bump js-yaml from 3.14.1 to 3.14.2 in /editors/code
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