implement semaphore for offset

Intended use is provide a sleep and wakeup primitive that can be used in the
contended case of other synchronization primitives.

Using threading.Semaphore would block the all thread when used so instead
implement offset ourself.