/// <summary> /// Whether the current thread is run by a worker for the given scheduler. /// </summary> public static bool IsRunningInWorkerFor <TWorkItem, TExecutor>(MultiThreadScheduler <TWorkItem, TExecutor> master) where TExecutor : IWorkExecutor <TWorkItem> => IsWorkerOwnedBy(_ofCurrentThread, master);
/// <summary> /// If the current thread is a worker thread from the given scheduler, return /// the worker object; otherwise null. /// </summary> public static Worker <TWorkItem, TExecutor>?TryGetCurrentWorkerFor <TWorkItem, TExecutor>(MultiThreadScheduler <TWorkItem, TExecutor> master) where TExecutor : IWorkExecutor <TWorkItem> { var worker = _ofCurrentThread; return(IsWorkerOwnedBy(worker, master) ? Unsafe.As <Worker <TWorkItem, TExecutor> >(worker !) : null); }