// Path: RxSwt/src/main/java/io/reactivex/swt/util/RxSwtPlugins.java
// public final class RxSwtPlugins {
// 
//     private static volatile Function<Callable<Scheduler>, Scheduler> onInitMainThreadHandler;
//     private static volatile Function<Scheduler, Scheduler> onMainThreadHandler;
// 
//     public static void setInitMainThreadSchedulerHandler(Function<Callable<Scheduler>, Scheduler> handler) {
//         onInitMainThreadHandler = handler;
//     }
// 
//     public static Scheduler initMainThreadScheduler(Callable<Scheduler> scheduler) {
//         if (scheduler == null) {
//             throw new NullPointerException("scheduler == null");
//         }
//         Function<Callable<Scheduler>, Scheduler> f = onInitMainThreadHandler;
//         if (f == null) {
//             return callRequireNonNull(scheduler);
//         }
//         return applyRequireNonNull(f, scheduler);
//     }
// 
//     public static void setMainThreadSchedulerHandler(Function<Scheduler, Scheduler> handler) {
//         onMainThreadHandler = handler;
//     }
// 
//     public static Scheduler onMainThreadScheduler(Scheduler scheduler) {
//         if (scheduler == null) {
//             throw new NullPointerException("scheduler == null");
//         }
//         Function<Scheduler, Scheduler> f = onMainThreadHandler;
//         if (f == null) {
//             return scheduler;
//         }
//         return apply(f, scheduler);
//     }
// 
//     /**
//      * Returns the current hook function.
//      * @return the hook function, may be null
//      */
//     public static Function<Callable<Scheduler>, Scheduler> getInitMainThreadSchedulerHandler() {
//         return onInitMainThreadHandler;
//     }
// 
//     /**
//      * Returns the current hook function.
//      * @return the hook function, may be null
//      */
//     public static Function<Scheduler, Scheduler> getOnMainThreadSchedulerHandler() {
//         return onMainThreadHandler;
//     }
// 
//     /**
//      * Removes all handlers and resets the default behavior.
//      */
//     public static void reset() {
//         setInitMainThreadSchedulerHandler(null);
//         setMainThreadSchedulerHandler(null);
//     }
// 
//     static Scheduler callRequireNonNull(Callable<Scheduler> s) {
//         try {
//             Scheduler scheduler = s.call();
//             if (scheduler == null) {
//                 throw new NullPointerException("Scheduler Callable returned null");
//             }
//             return scheduler;
//         } catch (Throwable ex) {
//             throw Exceptions.propagate(ex);
//         }
//     }
// 
//     static Scheduler applyRequireNonNull(Function<Callable<Scheduler>, Scheduler> f, Callable<Scheduler> s) {
//         Scheduler scheduler = apply(f,s);
//         if (scheduler == null) {
//             throw new NullPointerException("Scheduler Callable returned null");
//         }
//         return scheduler;
//     }
// 
//     static <T, R> R apply(Function<T, R> f, T t) {
//         try {
//             return f.apply(t);
//         } catch (Throwable ex) {
//             throw Exceptions.propagate(ex);
//         }
//     }
// 
//     private RxSwtPlugins() {
//         throw new AssertionError("No instances.");
//     }
// }


import org.eclipse.swt.widgets.Display;
import io.reactivex.Scheduler;
import io.reactivex.swt.util.RxSwtPlugins;
import java.util.concurrent.Callable;
/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.reactivex.swt.schedulers;




public class SwtSchedulers {

	private static final class MainHolder {
		static final Scheduler DEFAULT = new DisplayScheduler(Display.getDefault());
	}

	private static final Scheduler DEFAULT_DISPLAY_THREAD = RxSwtPlugins
			.initMainThreadScheduler(new Callable<Scheduler>() {
				@Override
				public Scheduler call() throws Exception {
					return MainHolder.DEFAULT;
				}
			});

	/**
	 * A {@link Scheduler} which executes actions on the SWT UI thread of the
	 * default {@link Display}.
	 */
	public static Scheduler defaultDisplayThread() {
		return RxSwtPlugins.onMainThreadScheduler(DEFAULT_DISPLAY_THREAD);
	}

	/**
	 * A {@link Scheduler} which executes actions on a {@code Display}.
	 */
	public static Scheduler from(Display display) {
// Path: RxSwt/src/main/java/io/reactivex/swt/util/RxSwtPlugins.java
// public final class RxSwtPlugins {
// 
//     private static volatile Function<Callable<Scheduler>, Scheduler> onInitMainThreadHandler;
//     private static volatile Function<Scheduler, Scheduler> onMainThreadHandler;
// 
//     public static void setInitMainThreadSchedulerHandler(Function<Callable<Scheduler>, Scheduler> handler) {
//         onInitMainThreadHandler = handler;
//     }
// 
//     public static Scheduler initMainThreadScheduler(Callable<Scheduler> scheduler) {
//         if (scheduler == null) {
//             throw new NullPointerException("scheduler == null");
//         }
//         Function<Callable<Scheduler>, Scheduler> f = onInitMainThreadHandler;
//         if (f == null) {
//             return callRequireNonNull(scheduler);
//         }
//         return applyRequireNonNull(f, scheduler);
//     }
// 
//     public static void setMainThreadSchedulerHandler(Function<Scheduler, Scheduler> handler) {
//         onMainThreadHandler = handler;
//     }
// 
//     public static Scheduler onMainThreadScheduler(Scheduler scheduler) {
//         if (scheduler == null) {
//             throw new NullPointerException("scheduler == null");
//         }
//         Function<Scheduler, Scheduler> f = onMainThreadHandler;
//         if (f == null) {
//             return scheduler;
//         }
//         return apply(f, scheduler);
//     }
// 
//     /**
//      * Returns the current hook function.
//      * @return the hook function, may be null
//      */
//     public static Function<Callable<Scheduler>, Scheduler> getInitMainThreadSchedulerHandler() {
//         return onInitMainThreadHandler;
//     }
// 
//     /**
//      * Returns the current hook function.
//      * @return the hook function, may be null
//      */
//     public static Function<Scheduler, Scheduler> getOnMainThreadSchedulerHandler() {
//         return onMainThreadHandler;
//     }
// 
//     /**
//      * Removes all handlers and resets the default behavior.
//      */
//     public static void reset() {
//         setInitMainThreadSchedulerHandler(null);
//         setMainThreadSchedulerHandler(null);
//     }
// 
//     static Scheduler callRequireNonNull(Callable<Scheduler> s) {
//         try {
//             Scheduler scheduler = s.call();
//             if (scheduler == null) {
//                 throw new NullPointerException("Scheduler Callable returned null");
//             }
//             return scheduler;
//         } catch (Throwable ex) {
//             throw Exceptions.propagate(ex);
//         }
//     }
// 
//     static Scheduler applyRequireNonNull(Function<Callable<Scheduler>, Scheduler> f, Callable<Scheduler> s) {
//         Scheduler scheduler = apply(f,s);
//         if (scheduler == null) {
//             throw new NullPointerException("Scheduler Callable returned null");
//         }
//         return scheduler;
//     }
// 
//     static <T, R> R apply(Function<T, R> f, T t) {
//         try {
//             return f.apply(t);
//         } catch (Throwable ex) {
//             throw Exceptions.propagate(ex);
//         }
//     }
// 
//     private RxSwtPlugins() {
//         throw new AssertionError("No instances.");
//     }
// }


// Path: RxSwt/src/main/java/io/reactivex/swt/schedulers/SwtSchedulers.java
import org.eclipse.swt.widgets.Display;
import io.reactivex.Scheduler;
import io.reactivex.swt.util.RxSwtPlugins;
import java.util.concurrent.Callable;

/*
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 * http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */
package io.reactivex.swt.schedulers;




public class SwtSchedulers {

	private static final class MainHolder {
		static final Scheduler DEFAULT = new DisplayScheduler(Display.getDefault());
	}

	private static final Scheduler DEFAULT_DISPLAY_THREAD = RxSwtPlugins
			.initMainThreadScheduler(new Callable<Scheduler>() {
				@Override
				public Scheduler call() throws Exception {
					return MainHolder.DEFAULT;
				}
			});

	/**
	 * A {@link Scheduler} which executes actions on the SWT UI thread of the
	 * default {@link Display}.
	 */
	public static Scheduler defaultDisplayThread() {
		return RxSwtPlugins.onMainThreadScheduler(DEFAULT_DISPLAY_THREAD);
	}

	/**
	 * A {@link Scheduler} which executes actions on a {@code Display}.
	 */
	public static Scheduler from(Display display) {
		return RxSwtPlugins.onMainThreadScheduler(new DisplayScheduler(display));