@Override
    public void close() throws E {
        // Alter state only when synchronized with calls to get().
        synchronized (monitor) {
            // Ensure we only try to close the generated resource once, by clearing it after picking it up here.
            T maybe = wrapped;
            wrapped = null;
            // Clear the factory, to signal this has been closed.
            factory = null;
            if (maybe != null) closer.close(maybe);
        }
    }
Composes the given memoized with a function taking its output as an argument to produce a new Memoized, with the given closer.
vespajlib/src/main/java/com/yahoo/yolean/concurrent/Memoized.java