sourceafQuickFlux::IconSrc.fan

using afConcurrent
using gfx::Image

const class IconSrc {
    private const AtomicMap images  := AtomicMap()

    internal Void disposeOfIcons() {
        images.vals.each { it->dispose }
        images.clear
    }
    
    @Operator
    Image? get(Uri? icoUri) {
        if (icoUri == null)
            return null
        return images.getOrAdd(icoUri) {
            Image(icoUri)
        }
    }   
}