reactor-core/src/main/java/reactor/core/scheduler/Schedulers.java
static CachedScheduler cache(AtomicReference<CachedScheduler> reference, String key, Supplier<Scheduler> supplier) {
		CachedScheduler s = reference.get();
		if (s != null) {
			return s;
		}
		s = new CachedScheduler(key, supplier.get());
		if (reference.compareAndSet(null, s)) {
			return s;
		}
		//the reference was updated in the meantime with a cached scheduler
		//fallback to it and dispose the extraneous one
		s._dispose();
		return reference.get();
	}
static CachedScheduler cache(AtomicReference<CachedScheduler> reference, String key, Supplier<Scheduler> supplier) {
		CachedScheduler s = reference.get();
		if (s != null) {
			return s;
		}
		s = new CachedScheduler(key, supplier.get());
		if (reference.compareAndSet(null, s)) {
			return s;
		}
		//the reference was updated in the meantime with a cached scheduler
		//fallback to it and dispose the extraneous one
		s._dispose();
		return reference.get();
	}
static CachedScheduler cache ( AtomicReference < CachedScheduler > reference , String key , Supplier < Scheduler > supplier ) { CachedScheduler s = reference . get ( ) ; if ( s != null ) { return s ; } s = new CachedScheduler ( key , supplier . get ( ) ) ; if ( reference . compareAndSet ( null , s ) ) { return s ; } //the reference was updated in the meantime with a cached scheduler //fallback to it and dispose the extraneous one s . _dispose ( ) ; return reference . get ( ) ; }
Get a {@link CachedScheduler} out of the {@code reference} or create one using the
{@link Supplier} if the reference is empty, effectively creating a single instance
to be reused as a default scheduler for the given {@code key} category.

@param reference the cache reference that holds the scheduler
@param key the "name" for the Scheduler's category/type
@param supplier the {@link Scheduler} generator to use and wrap into a {@link CachedScheduler}.
Note that in case of a race, an extraneous Scheduler can be created, but it'll get
immediately {@link Scheduler#dispose() disposed}.
@return a {@link CachedScheduler} to be reused, either pre-existing or created
Get a { @link CachedScheduler } out of the { @code reference } or create one using the { @link Supplier } if the reference is empty effectively creating a single instance to be reused as a default scheduler for the given { @code key } category .