public ClassLock lockWhile(Class<?> clazz, BooleanSupplier interruptCondition) {
        synchronized (monitor) {
            while (classLocks.containsKey(clazz.getName())) {
                try {
                    monitor.wait();
                } catch (InterruptedException ignored) {
                }

                if (!interruptCondition.getAsBoolean()) {
                    throw new LockInterruptException();
                }
            }

            ClassLock classLock = new ClassLock(this, clazz);
            classLocks.put(clazz.getName(), classLock);
            return classLock;
        }
    }
Locks key. This will block until the key is acquired or the interrupt condition is
no longer true. Condition is only checked at the start, everytime a lock is released
and when {@link #interrupt()} is called.

Users of this <b>must</b> close any lock acquired.

@throws LockInterruptException if interruptCondition returned false before
the lock could be acquired
vespajlib/src/main/java/com/yahoo/concurrent/classlock/ClassLocking.java