RFR: 8255582: Introduce SemaphoreLock and SemaphoreLocker

Kim Barrett kbarrett at openjdk.java.net
Thu Oct 29 11:44:44 UTC 2020


On Thu, 29 Oct 2020 10:01:22 GMT, Stefan Karlsson <stefank at openjdk.org> wrote:

> Semaphores can be used as low-level locks, but the readability of the code using them could be better. I propose that we introduce two new classes:
> 
> SemaphoreLock - which provides the operations lock, unlock, try_lock.
> 
> SemaphoreLocker - Equivalent to MutexLocker.

I don't think we should be using semaphores as a substitute for fixing mutex rankings or using some rankless mutex (like PlatformMutex).  So I'm not in favor of this change.

-------------

PR: https://git.openjdk.java.net/jdk/pull/927


More information about the hotspot-dev mailing list