-
Notifications
You must be signed in to change notification settings - Fork 31
Possible p() & v() confusion #13
New issue
Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? # to your account
Comments
Yes you are absolutely correct, the traditional meaning of the terms is unfortunately mixed in this library. However if you think the letters could mean V = verhogen = increase and P = passeren = pass, then we can build a meaningful explanation for the function names. As you probably have noted the implementation is based on a fixed number of tokens distributed to the consumers. Now Retrospectively thinking I should have probably never used single letter function names anyway but something like |
Thanks for the confirmation. Any chance the API would be updated with more standard names? |
The function names `v()` and `p()` in this library were accidentally reversed from the tradition. Since the function names might be a bit confusing even if named correctly, we should rename them as `acquire()` and `release()` but also provide the old names for backwards compatibility. Fixes #13
* New function names for clarity The function names `v()` and `p()` in this library were accidentally reversed from the tradition. Since the function names might be a bit confusing even if named correctly, we should rename them as `acquire()` and `release()` but also provide the old names for backwards compatibility. Fixes #13 * Missed this * Add deprecation warnings * Fix ts definitions
Looking at the source code and the examples, it seems to me that the library is using
p()
to signal/free up a resource, whereasv()
is used to wait/"block" on the semaphore.However, according to the definition of a semaphore, the uses of
p()
andv()
are the other way around. Some resources to verify are:Please let me know if I'm misunderstanding the use case here. :)
The text was updated successfully, but these errors were encountered: