Extract pruning and only wait for rotation to complete.

Previously all threads had to wait on the combined rotation and pruning
operation to finish. Now all threads will only have to wait on the rotation
to finish and one unlucky thread will get the pruning lock (tryLock())
and have its transaction stalled while doing the pruning.