Refactor code once more for yet better thread safety at shutdown.
Instead of using flockfile, we use a simple spin lock now. This
is even a bit faster than using flockfile, and does not have any
issues at shutdown, when the file was deleted already.
Also, the spin lock can easily be combined with the check for
when the timer thread should be stopped.
Furthermore, the code is restructured to ensure the thread-unsafe
API is only ever getting called while the lock is held.
To simplify future development, some debug log can now be enabled
which will trace the heaptrack execution.