Imported Upstream version 3.6.0

Former-commit-id: da6be194a6b1221998fc28233f2503bd61dd9d14
This commit is contained in:
Jo Shields
2014-08-13 10:39:27 +01:00
commit a575963da9
50588 changed files with 8155799 additions and 0 deletions

View File

@@ -0,0 +1,21 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Concurrency
{
/// <summary>
/// Represents a work item that has been scheduled.
/// </summary>
/// <typeparam name="TAbsolute">Absolute time representation type.</typeparam>
public interface IScheduledItem<TAbsolute>
{
/// <summary>
/// Gets the absolute time at which the item is due for invocation.
/// </summary>
TAbsolute DueTime { get; }
/// <summary>
/// Invokes the work item.
/// </summary>
void Invoke();
}
}

View File

@@ -0,0 +1,44 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
namespace System.Reactive.Concurrency
{
/// <summary>
/// Represents an object that schedules units of work.
/// </summary>
public interface IScheduler
{
/// <summary>
/// Gets the scheduler's notion of current time.
/// </summary>
DateTimeOffset Now { get; }
/// <summary>
/// Schedules an action to be executed.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
IDisposable Schedule<TState>(TState state, Func<IScheduler, TState, IDisposable> action);
/// <summary>
/// Schedules an action to be executed after dueTime.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <param name="dueTime">Relative time after which to execute the action.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
IDisposable Schedule<TState>(TState state, TimeSpan dueTime, Func<IScheduler, TState, IDisposable> action);
/// <summary>
/// Schedules an action to be executed at dueTime.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <param name="dueTime">Absolute time at which to execute the action.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
IDisposable Schedule<TState>(TState state, DateTimeOffset dueTime, Func<IScheduler, TState, IDisposable> action);
}
}

View File

@@ -0,0 +1,26 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Reactive.Disposables;
namespace System.Reactive.Concurrency
{
/// <summary>
/// Scheduler with support for starting long-running tasks.
/// This type of scheduler can be used to run loops more efficiently instead of using recursive scheduling.
/// </summary>
public interface ISchedulerLongRunning
{
/// <summary>
/// Schedules a long-running piece of work.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">State passed to the action to be executed.</param>
/// <param name="action">Action to be executed.</param>
/// <returns>The disposable object used to cancel the scheduled action (best effort).</returns>
/// <remarks>
/// <para><b>Notes to implementers</b></para>
/// The returned disposable object should not prevent the work from starting, but only set the cancellation flag passed to the specified action.
/// </remarks>
IDisposable ScheduleLongRunning<TState>(TState state, Action<TState, ICancelable> action);
}
}

View File

@@ -0,0 +1,23 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System.Reactive.Disposables;
namespace System.Reactive.Concurrency
{
/// <summary>
/// Scheduler with support for running periodic tasks.
/// This type of scheduler can be used to run timers more efficiently instead of using recursive scheduling.
/// </summary>
public interface ISchedulerPeriodic
{
/// <summary>
/// Schedules a periodic piece of work.
/// </summary>
/// <typeparam name="TState">The type of the state passed to the scheduled action.</typeparam>
/// <param name="state">Initial state passed to the action upon the first iteration.</param>
/// <param name="period">Period for running the work periodically.</param>
/// <param name="action">Action to be executed, potentially updating the state.</param>
/// <returns>The disposable object used to cancel the scheduled recurring action (best effort).</returns>
IDisposable SchedulePeriodic<TState>(TState state, TimeSpan period, Func<TState, TState> action);
}
}

View File

@@ -0,0 +1,17 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
namespace System.Reactive.Concurrency
{
/// <summary>
/// Abstraction for a stopwatch to compute time relative to a starting point.
/// </summary>
public interface IStopwatch
{
/// <summary>
/// Gets the time elapsed since the stopwatch object was obtained.
/// </summary>
TimeSpan Elapsed { get; }
}
}

View File

@@ -0,0 +1,25 @@
// Copyright (c) Microsoft Open Technologies, Inc. All rights reserved. See License.txt in the project root for license information.
using System;
namespace System.Reactive.Concurrency
{
/*
* The ability to request a stopwatch object has been introduced in Rx v2.0 to reduce the
* number of allocations made by operators that use absolute time to compute relative time
* diffs, such as TimeInterval and Delay. This causes a large number of related objects to
* be allocated in the BCL, e.g. System.Globalization.DaylightTime.
*/
/// <summary>
/// Provider for IStopwatch objects.
/// </summary>
public interface IStopwatchProvider
{
/// <summary>
/// Starts a new stopwatch object.
/// </summary>
/// <returns>New stopwatch object; started at the time of the request.</returns>
IStopwatch StartStopwatch();
}
}