// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the Apache 2.0 License.
// See the LICENSE file in the project root for more information.
using System.ComponentModel;
using System.Reactive.PlatformServices;
namespace System.Reactive.Concurrency
{
///
/// (Infrastructure) Concurrency abstraction layer.
///
internal static class ConcurrencyAbstractionLayer
{
///
/// Gets the current CAL. If no CAL has been set yet, it will be initialized to the default.
///
public static IConcurrencyAbstractionLayer Current { get; } = Initialize();
private static IConcurrencyAbstractionLayer Initialize()
{
#pragma warning disable CS0618 // Type or member is obsolete
return PlatformEnlightenmentProvider.Current.GetService() ?? new DefaultConcurrencyAbstractionLayer();
#pragma warning restore CS0618 // Type or member is obsolete
}
}
///
/// (Infrastructure) Concurrency abstraction layer interface.
///
///
/// This type is used by the Rx infrastructure and not meant for public consumption or implementation.
/// No guarantees are made about forward compatibility of the type's functionality and its usage.
///
[EditorBrowsable(EditorBrowsableState.Never)]
public interface IConcurrencyAbstractionLayer
{
///
/// Queues a method for execution at the specified relative time.
///
/// Method to execute.
/// State to pass to the method.
/// Time to execute the method on.
/// Disposable object that can be used to stop the timer.
IDisposable StartTimer(Action