[TASK] Improve Locker

Code cleanup for locker and fix of semaphore locking.
It is now possible to reuse a semaphore.

Resolves: #40420
Releases: 6.2
Change-Id: I843aca1f9fa3d070ce0a508a27d3c433725991fa
Reviewed-on: https://review.typo3.org/28159
Reviewed-by: Thomas Maroschik
Tested-by: Thomas Maroschik