using System; namespace UniRx { public interface IOptimizedObservable : IObservable { bool IsRequiredSubscribeOnCurrentThread(); } public static class OptimizedObservableExtensions { public static bool IsRequiredSubscribeOnCurrentThread(this IObservable source) { var obs = source as IOptimizedObservable; if (obs == null) return true; return obs.IsRequiredSubscribeOnCurrentThread(); } public static bool IsRequiredSubscribeOnCurrentThread(this IObservable source, IScheduler scheduler) { if (scheduler == Scheduler.CurrentThread) return true; return IsRequiredSubscribeOnCurrentThread(source); } } }