Imported Upstream version 4.0.0~alpha1

Former-commit-id: 806294f5ded97629b74c85c09952f2a74fe182d9
This commit is contained in:
Jo Shields
2015-04-07 09:35:12 +01:00
parent 283343f570
commit 3c1f479b9d
22469 changed files with 2931443 additions and 869343 deletions

View File

@@ -1,99 +0,0 @@
2010-07-07 Jérémie Laval <jeremie.laval@gmail.com>
* Parallel.cs: Fix Parallel.Invoke to use all data supplied in
ParallelOptions
* ParallelOptions.cs: Use CancellationToken.None for initialization
2010-04-15 Jérémie Laval <jeremie.laval@gmail.com>
* Future.cs:
* Task.cs:
* TaskCanceledException.cs:
* TaskContinuationOptions.cs:
* TaskCreationOptions.cs:
* TaskFactory.cs:
* TaskScheduler.cs:
* TaskStatus.cs: Add BOOTSTRAP_NET_4_0 define
2010-03-02 Jérémie Laval <jeremie.laval@gmail.com>
* Task.cs: If we add a continuation when the Task is already finished
forces its schedule as a Task instead of executing on the calling thread.
* TaskFactory.cs: Add ContinueWhenAny implementation when returning Task
2010-02-24 Rodrigo Kumpera <rkumpera@novell.com>
* TaskContinuationOptions.cs: Use RC values.
* TaskCreationOptions.cs: Ditto.
2010-02-23 Jérémie Laval <jeremie.laval@gmail.com>
* Task.cs: Fix for continuation processing not happening
in case of Faulted or Canceled.
2010-02-02 Jérémie Laval <jeremie.laval@gmail.com>
* Task.cs: Fix autocomplete mistake (s/Exception/exception/).
Let continuation processing happens at the right moment when
task has child.
2010-02-02 Jérémie Laval <jeremie.laval@gmail.com>
* Future.cs:
* Parallel.cs:
* ParallelLoopState.cs:
* Task.cs:
* TaskCompletionSource.cs:
* TaskContinuationOptions.cs:
* TaskCreationOptions.cs:
* TaskFactory.cs:
* TaskScheduler.cs:
* UnobservedTaskExceptionEventArgs.cs: Port to .NET 4 beta 2 API
* SimpleConcurrentBag.cs: Add a simpler implementation of ConcurrentBag
for use with parallel loops as ConcurrentBag was moved to System
2009-08-19 Jérémie Laval <jeremie.laval@gmail.com>
* Task.cs: Refactor Wait methods.
2009-08-11 Jérémie Laval <jeremie.laval@gmail.com>
* Future.cs: Add static to Factory property
2009-08-11 Jérémie Laval <jeremie.laval@gmail.com>
* Task.cs: Make WaitAny uses general continuation
framework.
2009-08-11 Jérémie Laval <jeremie.laval@gmail.com>
* TaskFactory.cs: Fix methods signature.
2009-08-05 Jérémie Laval <jeremie.laval@gmail.com>
* Future.cs: Fix for Future, when using TaskCompletionSource
don't try to run Wait before returning value
2009-07-31 Jérémie Laval <jeremie.laval@gmail.com>
* Task.cs:
* Future.cs:
* TaskFactory.cs:
* TaskCanceledException.cs:
* TaskSchedulerException.cs:
* Internal/SchedulerProxy.cs: Make System.Threading.Tasks API fully 4.0 b1 compliant.
* TaskCompletionSource.cs: Add TaskCompletionSource class
2009-07-27 Jérémie Laval <jeremie.laval@gmail.com>
* Future.cs:
* Task.cs:
* TaskCanceledException.cs:
* TaskContinuationOptions.cs:
* TaskCreationOptions.cs:
* TaskFactory.cs:
* TaskScheduler.cs:
* TaskSchedulerException.cs:
* TaskStatus.cs: Added ParallelFx files for System.Threading.Tasks namespace

View File

@@ -1,273 +0,0 @@
//
// ConcurrentExclusiveSchedulerPair.cs
//
// Authors:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (c) 2011 Jérémie "Garuma" Laval
// Copyright 2012 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
#if NET_4_5
using System;
using System.Threading;
using System.Collections.Generic;
using System.Collections.Concurrent;
using System.Diagnostics;
namespace System.Threading.Tasks
{
[DebuggerDisplay ("Concurrent={ConcurrentTaskCount}, Exclusive={ExclusiveTaskCount}")]
[DebuggerTypeProxy (typeof (SchedulerDebuggerView))]
public class ConcurrentExclusiveSchedulerPair
{
sealed class SchedulerDebuggerView
{
readonly ConcurrentExclusiveSchedulerPair owner;
public SchedulerDebuggerView (ConcurrentExclusiveSchedulerPair owner)
{
this.owner = owner;
}
public IEnumerable<Task> ScheduledConcurrent {
get {
return owner.concurrentTasks;
}
}
public IEnumerable<Task> ScheduledExclusive {
get {
return owner.exclusiveTasks;
}
}
public TaskScheduler TargetScheduler {
get {
return owner.target;
}
}
}
readonly int maxConcurrencyLevel;
readonly int maxItemsPerTask;
readonly TaskScheduler target;
readonly TaskFactory factory;
readonly Action taskHandler;
readonly ConcurrentQueue<Task> concurrentTasks = new ConcurrentQueue<Task> ();
readonly ConcurrentQueue<Task> exclusiveTasks = new ConcurrentQueue<Task> ();
//readonly ReaderWriterLockSlim rwl = new ReaderWriterLockSlim ();
readonly TaskCompletionSource<object> completion = new TaskCompletionSource<object> ();
readonly InnerTaskScheduler concurrent;
readonly InnerTaskScheduler exclusive;
int numTask;
class InnerTaskScheduler : TaskScheduler
{
readonly ConcurrentExclusiveSchedulerPair scheduler;
readonly ConcurrentQueue<Task> queue;
public InnerTaskScheduler (ConcurrentExclusiveSchedulerPair scheduler,
ConcurrentQueue<Task> queue)
{
this.scheduler = scheduler;
this.queue = queue;
}
public int TaskCount {
get {
return queue.Count;
}
}
public override int MaximumConcurrencyLevel {
get {
return scheduler.maxConcurrencyLevel;
}
}
protected internal override void QueueTask (Task t)
{
scheduler.DoQueue (t, queue);
}
protected override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
{
if (task.Status != TaskStatus.Created)
return false;
task.RunSynchronously (scheduler.target);
return true;
}
public void Execute (Task t)
{
TryExecuteTask (t);
}
[MonoTODO ("Only useful for debugger support")]
protected override IEnumerable<Task> GetScheduledTasks ()
{
throw new NotImplementedException ();
}
}
public ConcurrentExclusiveSchedulerPair () : this (TaskScheduler.Current)
{
}
public ConcurrentExclusiveSchedulerPair (TaskScheduler taskScheduler) : this (taskScheduler, taskScheduler.MaximumConcurrencyLevel)
{
}
public ConcurrentExclusiveSchedulerPair (TaskScheduler taskScheduler, int maxConcurrencyLevel)
: this (taskScheduler, maxConcurrencyLevel, -1)
{
}
public ConcurrentExclusiveSchedulerPair (TaskScheduler taskScheduler, int maxConcurrencyLevel, int maxItemsPerTask)
{
this.target = taskScheduler;
this.maxConcurrencyLevel = maxConcurrencyLevel;
this.maxItemsPerTask = maxItemsPerTask;
this.factory = new TaskFactory (taskScheduler);
this.taskHandler = InternalTaskProcesser;
this.concurrent = new InnerTaskScheduler (this, concurrentTasks);
this.exclusive = new InnerTaskScheduler (this, exclusiveTasks);
}
public void Complete ()
{
completion.SetResult (null);
}
public TaskScheduler ConcurrentScheduler {
get {
return concurrent;
}
}
private int ConcurrentTaskCount {
get {
return concurrent.TaskCount;
}
}
public TaskScheduler ExclusiveScheduler {
get {
return exclusive;
}
}
private int ExclusiveTaskCount {
get {
return exclusive.TaskCount;
}
}
public Task Completion {
get {
return completion.Task;
}
}
void DoQueue (Task task, ConcurrentQueue<Task> queue)
{
queue.Enqueue (task);
SpinUpTasks ();
}
void InternalTaskProcesser ()
{
int times = 0;
// const int lockWaitTime = 2;
while (!concurrentTasks.IsEmpty || !exclusiveTasks.IsEmpty) {
if (maxItemsPerTask != -1 && ++times == maxItemsPerTask)
break;
throw new NotImplementedException ();
/*
bool locked = false;
try {
if (!concurrentTasks.IsEmpty && rwl.TryEnterReadLock (lockWaitTime)) {
locked = true;
Task task;
while (concurrentTasks.TryDequeue (out task)) {
RunTask (task);
}
}
} finally {
if (locked) {
rwl.ExitReadLock ();
locked = false;
}
}
try {
if (!exclusiveTasks.IsEmpty && rwl.TryEnterWriteLock (lockWaitTime)) {
locked = true;
Task task;
while (exclusiveTasks.TryDequeue (out task)) {
RunTask (task);
}
}
} finally {
if (locked) {
rwl.ExitWriteLock ();
}
}
*/
}
// TODO: there's a race here, task adding + spinup check may be done while here
Interlocked.Decrement (ref numTask);
}
void SpinUpTasks ()
{
int currentTaskNumber;
do {
currentTaskNumber = numTask;
if (currentTaskNumber >= maxConcurrencyLevel)
return;
} while (Interlocked.CompareExchange (ref numTask, currentTaskNumber + 1, currentTaskNumber) != currentTaskNumber);
factory.StartNew (taskHandler);
}
void RunTask (Task task)
{
concurrent.Execute (task);
}
}
}
#endif

View File

@@ -1,219 +0,0 @@
//
// CyclicDeque.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2009 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Collections.Generic;
using System.Threading;
#if INSIDE_MONO_PARALLEL
namespace Mono.Threading.Tasks
#else
namespace System.Threading.Tasks
#endif
{
#if INSIDE_MONO_PARALLEL
public
#endif
class CyclicDeque<T> : IConcurrentDeque<T>
{
const int BaseSize = 11;
int bottom;
int top;
int upperBound;
CircularArray<T> array = new CircularArray<T> (BaseSize);
public void PushBottom (T obj)
{
int b = bottom;
var a = array;
// Take care of growing
var size = b - top - upperBound;
if (size > a.Size) {
upperBound = top;
a = a.Grow (b, upperBound);
array = a;
}
// Register the new value
a.segment[b % a.size] = obj;
Interlocked.Increment (ref bottom);
}
public PopResult PopBottom (out T obj)
{
obj = default (T);
int b = Interlocked.Decrement (ref bottom);
var a = array;
int t = top;
int size = b - t;
if (size < 0) {
// Set bottom to t
Interlocked.Add (ref bottom, t - b);
return PopResult.Empty;
}
obj = a.segment[b % a.size];
if (size > 0)
return PopResult.Succeed;
Interlocked.Add (ref bottom, t + 1 - b);
if (Interlocked.CompareExchange (ref top, t + 1, t) != t)
return PopResult.Empty;
return PopResult.Succeed;
}
public bool PeekBottom (out T obj)
{
obj = default (T);
int b = Interlocked.Decrement (ref bottom);
var a = array;
int t = top;
int size = b - t;
if (size < 0)
return false;
obj = a.segment[b % a.size];
return true;
}
public PopResult PopTop (out T obj)
{
obj = default (T);
int t = top;
int b = bottom;
if (b - t <= 0)
return PopResult.Empty;
if (Interlocked.CompareExchange (ref top, t + 1, t) != t)
return PopResult.Abort;
var a = array;
obj = a.segment[t % a.size];
return PopResult.Succeed;
}
internal bool PeekTop (out T obj)
{
obj = default (T);
int t = top;
int b = bottom;
if (b - t <= 0)
return false;
var a = array;
obj = a.segment[t % a.size];
return true;
}
public IEnumerable<T> GetEnumerable ()
{
var a = array;
return a.GetEnumerable (bottom, ref top);
}
public bool IsEmpty {
get {
int t = top;
int b = bottom;
return b - t <= 0;
}
}
}
internal class CircularArray<T>
{
readonly int baseSize;
public readonly int size;
public readonly T[] segment;
public CircularArray (int baseSize)
{
this.baseSize = baseSize;
this.size = 1 << baseSize;
this.segment = new T[size];
}
public int Size {
get {
return size;
}
}
public T this[int index] {
get {
return segment[index % size];
}
set {
segment[index % size] = value;
}
}
public CircularArray<T> Grow (int bottom, int top)
{
var grow = new CircularArray<T> (baseSize + 1);
for (int i = top; i < bottom; i++) {
grow.segment[i] = segment[i % size];
}
return grow;
}
public IEnumerable<T> GetEnumerable (int bottom, ref int top)
{
int instantTop = top;
T[] slice = new T[bottom - instantTop];
int destIndex = -1;
for (int i = instantTop; i < bottom; i++)
slice[++destIndex] = segment[i % size];
return RealGetEnumerable (slice, bottom, top, instantTop);
}
IEnumerable<T> RealGetEnumerable (T[] slice, int bottom, int realTop, int initialTop)
{
int destIndex = (int)(realTop - initialTop - 1);
for (int i = realTop; i < bottom; ++i)
yield return slice[++destIndex];
}
}
}
#endif

View File

@@ -26,7 +26,6 @@
//
//
#if NET_4_5
namespace System.Threading.Tasks
{
@@ -72,4 +71,3 @@ namespace System.Threading.Tasks
}
}
#endif

View File

@@ -1,51 +0,0 @@
//
// IConcurrentDeque.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2011 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Collections.Generic;
using System.Threading;
#if INSIDE_MONO_PARALLEL
namespace Mono.Threading.Tasks
#else
namespace System.Threading.Tasks
#endif
{
#if INSIDE_MONO_PARALLEL
public
#endif
interface IConcurrentDeque<T>
{
void PushBottom (T obj);
PopResult PopBottom (out T obj);
PopResult PopTop (out T obj);
IEnumerable<T> GetEnumerable ();
}
}
#endif

File diff suppressed because it is too large Load Diff

View File

@@ -1,51 +0,0 @@
//
// ParallelLoopResult.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2009 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
namespace System.Threading.Tasks
{
public struct ParallelLoopResult
{
internal ParallelLoopResult (long? lowest, bool isCompleted) : this ()
{
LowestBreakIteration = lowest;
IsCompleted = isCompleted;
}
public long? LowestBreakIteration {
get;
private set;
}
public bool IsCompleted {
get;
private set;
}
}
}
#endif

View File

@@ -1,97 +0,0 @@
// ParallelState.cs
//
// Copyright (c) 2008 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
#if NET_4_0
using System;
using System.Threading;
namespace System.Threading.Tasks
{
[System.Diagnostics.DebuggerDisplayAttribute ("ShouldExitCurrentIteration = {ShouldExitCurrentIteration}")]
public class ParallelLoopState
{
internal class ExternalInfos
{
public bool IsStopped;
public AtomicBooleanValue IsBroken = new AtomicBooleanValue ();
public volatile bool IsExceptional;
public long? LowestBreakIteration;
}
ExternalInfos extInfos;
internal ParallelLoopState (ExternalInfos extInfos)
{
this.extInfos = extInfos;
}
public bool IsStopped {
get {
return extInfos.IsStopped;
}
}
public bool IsExceptional {
get {
return extInfos.IsExceptional;
}
}
public long? LowestBreakIteration {
get {
return extInfos.LowestBreakIteration;
}
}
internal int CurrentIteration {
get;
set;
}
public bool ShouldExitCurrentIteration {
get {
return IsExceptional || IsStopped;
}
}
public void Break ()
{
if (extInfos.IsStopped)
throw new InvalidOperationException ("The Stop method was previously called. Break and Stop may not be used in combination by iterations of the same loop.");
bool result = extInfos.IsBroken.Exchange (true);
if (!result)
extInfos.LowestBreakIteration = CurrentIteration;
}
public void Stop ()
{
if (extInfos.IsBroken.Value)
throw new InvalidOperationException ("The Break method was previously called. Break and Stop may not be used in combination by iterations of the same loop.");
extInfos.IsStopped = true;
}
}
}
#endif

View File

@@ -1,61 +0,0 @@
//
// ParallelOptions.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2009 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Threading;
namespace System.Threading.Tasks
{
public class ParallelOptions
{
internal static readonly ParallelOptions Default = new ParallelOptions ();
public ParallelOptions()
{
this.MaxDegreeOfParallelism = -1;
this.CancellationToken = CancellationToken.None;
this.TaskScheduler = TaskScheduler.Current;
}
public CancellationToken CancellationToken {
get;
set;
}
public int MaxDegreeOfParallelism {
get;
set;
}
public TaskScheduler TaskScheduler {
get;
set;
}
}
}
#endif

View File

@@ -1,49 +0,0 @@
//
// PopResult.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2011 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Collections.Generic;
using System.Threading;
#if INSIDE_MONO_PARALLEL
namespace Mono.Threading.Tasks
#else
namespace System.Threading.Tasks
#endif
{
#if INSIDE_MONO_PARALLEL
public
#endif
enum PopResult {
Succeed,
Empty,
Abort
}
}
#endif

View File

@@ -1,90 +0,0 @@
//
// SimpleConcurrentBag.cs
//
// Author:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
//
// Copyright (c) 2009 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Threading;
namespace System.Threading.Tasks
{
internal class SimpleConcurrentBag<T>
{
readonly IConcurrentDeque<T>[] deques;
readonly bool unique;
int index = -1;
[ThreadStatic]
int stealIndex;
public SimpleConcurrentBag (int num)
{
deques = new CyclicDeque<T>[num];
for (int i = 0; i < deques.Length; i++) {
deques[i] = new CyclicDeque<T> ();
}
unique = num <= 1;
}
public int GetNextIndex ()
{
return Interlocked.Increment (ref index);
}
public bool TryTake (int index, out T value)
{
value = default (T);
return deques[index].PopBottom (out value) == PopResult.Succeed;
}
public bool TrySteal (int index, out T value)
{
value = default (T);
if (unique)
return false;
const int roundThreshold = 3;
for (int round = 0; round < roundThreshold; ++round) {
if (stealIndex == index)
stealIndex = (stealIndex + 1) % deques.Length;
if (deques[(stealIndex = (stealIndex + 1) % deques.Length)].PopTop (out value) == PopResult.Succeed)
return true;
}
return false;
}
public void Add (int index, T value)
{
deques[index].PushBottom (value);
}
}
}
#endif

View File

@@ -1,80 +0,0 @@
//
// SynchronizationContextScheduler.cs
//
// Authors:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (c) 2011 Novell
// Copyright 2014 Xamarin Inc (http://www.xamarin.com).
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Threading;
namespace System.Threading.Tasks
{
sealed class SynchronizationContextScheduler : TaskScheduler
{
readonly SynchronizationContext ctx;
readonly SendOrPostCallback callback;
public SynchronizationContextScheduler (SynchronizationContext ctx)
{
this.ctx = ctx;
this.callback = TaskLaunchWrapper;
}
protected internal override void QueueTask (Task task)
{
ctx.Post (callback, task);
}
void TaskLaunchWrapper (object obj)
{
TryExecuteTask ((Task)obj);
}
protected override System.Collections.Generic.IEnumerable<Task> GetScheduledTasks ()
{
throw new System.NotImplementedException();
}
protected internal override bool TryDequeue (Task task)
{
return false;
}
protected override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
{
return ctx == SynchronizationContext.Current && TryExecuteTask (task);
}
public override int MaximumConcurrencyLevel {
get {
return 1;
}
}
}
}
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,66 +0,0 @@
// TaskCanceledException.cs
//
// Copyright (c) 2008 Jérémie "Garuma" Laval
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
#if NET_4_0
using System;
using System.Runtime.Serialization;
namespace System.Threading.Tasks
{
[Serializable]
public class TaskCanceledException : OperationCanceledException
{
Task task;
public TaskCanceledException (): base ()
{
}
public TaskCanceledException (string message): base (message)
{
}
public TaskCanceledException (string message, Exception innerException): base (message, innerException)
{
}
public TaskCanceledException (Task task): base ("The Task was canceled")
{
this.task = task;
}
protected TaskCanceledException (SerializationInfo info, StreamingContext context)
: base (info, context)
{
}
public Task Task {
get {
return task;
}
}
}
}
#endif

View File

@@ -1,80 +0,0 @@
//
// TaskCompletionQueue.cs
//
// Authors:
// Jérémie Laval <jeremie dot laval at xamarin dot com>
//
// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
#if NET_4_0
using System;
using System.Threading;
using System.Collections.Generic;
using System.Collections.Concurrent;
namespace System.Threading.Tasks
{
internal struct TaskCompletionQueue<TCompletion> where TCompletion : class
{
TCompletion single;
ConcurrentOrderedList<TCompletion> completed;
public void Add (TCompletion continuation)
{
if (single == null && Interlocked.CompareExchange (ref single, continuation, null) == null)
return;
if (completed == null)
Interlocked.CompareExchange (ref completed, new ConcurrentOrderedList<TCompletion> (), null);
completed.TryAdd (continuation);
}
public bool Remove (TCompletion continuation)
{
TCompletion temp = single;
if (temp != null && temp == continuation && Interlocked.CompareExchange (ref single, null, continuation) == continuation)
return true;
if (completed != null)
return completed.TryRemove (continuation);
return false;
}
public bool HasElements {
get {
return single != null || (completed != null && completed.Count != 0);
}
}
public bool TryGetNextCompletion (out TCompletion continuation)
{
continuation = null;
if (single != null && (continuation = Interlocked.Exchange (ref single, null)) != null)
return true;
return completed != null && completed.TryPop (out continuation);
}
}
}
#endif

View File

@@ -1,131 +0,0 @@
//
// TaskCompletionSource.cs
//
// Authors:
// Jérémie "Garuma" Laval <jeremie.laval@gmail.com>
// Marek Safar <marek.safar@gmail.com>
//
// Copyright (c) 2009 Jérémie "Garuma" Laval
// Copyright 2011 Xamarin, Inc (http://www.xamarin.com)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
#if NET_4_0
using System;
using System.Collections.Generic;
namespace System.Threading.Tasks
{
public class TaskCompletionSource<TResult>
{
readonly Task<TResult> source;
public TaskCompletionSource ()
: this (null, TaskCreationOptions.None)
{
}
public TaskCompletionSource (object state)
: this (state, TaskCreationOptions.None)
{
}
public TaskCompletionSource (TaskCreationOptions creationOptions)
: this (null, creationOptions)
{
}
public TaskCompletionSource (object state, TaskCreationOptions creationOptions)
{
if ((creationOptions & System.Threading.Tasks.Task.WorkerTaskNotSupportedOptions) != 0)
throw new ArgumentOutOfRangeException ("creationOptions");
source = new Task<TResult> (TaskActionInvoker.Empty, state, CancellationToken.None, creationOptions, null);
source.SetupScheduler (TaskScheduler.Current);
}
public void SetCanceled ()
{
if (!TrySetCanceled ())
ThrowInvalidException ();
}
public void SetException (Exception exception)
{
if (exception == null)
throw new ArgumentNullException ("exception");
SetException (new Exception[] { exception });
}
public void SetException (IEnumerable<Exception> exceptions)
{
if (!TrySetException (exceptions))
ThrowInvalidException ();
}
public void SetResult (TResult result)
{
if (!TrySetResult (result))
ThrowInvalidException ();
}
static void ThrowInvalidException ()
{
throw new InvalidOperationException ("The underlying Task is already in one of the three final states: RanToCompletion, Faulted, or Canceled.");
}
public bool TrySetCanceled ()
{
return source.TrySetCanceled ();
}
public bool TrySetException (Exception exception)
{
if (exception == null)
throw new ArgumentNullException ("exception");
return TrySetException (new Exception[] { exception });
}
public bool TrySetException (IEnumerable<Exception> exceptions)
{
if (exceptions == null)
throw new ArgumentNullException ("exceptions");
var aggregate = new AggregateException (exceptions);
if (aggregate.InnerExceptions.Count == 0)
throw new ArgumentNullException ("exceptions");
return source.TrySetException (aggregate, false, false);
}
public bool TrySetResult (TResult result)
{
return source.TrySetResult (result);
}
public Task<TResult> Task {
get {
return source;
}
}
}
}
#endif

View File

@@ -26,7 +26,6 @@
//
//
#if NET_4_0
namespace System.Threading.Tasks
{
@@ -48,4 +47,3 @@ namespace System.Threading.Tasks
}
}
#endif

View File

@@ -26,7 +26,6 @@
//
//
#if NET_4_5
using System;
using System.Runtime.CompilerServices;
@@ -45,4 +44,3 @@ namespace System.Threading.Tasks
}
}
#endif

View File

@@ -1,392 +0,0 @@
//
// TaskContinuation.cs
//
// Authors:
// Jérémie Laval <jeremie dot laval at xamarin dot com>
// Marek Safar <marek.safar@gmail.com>
//
// Copyright 2011 Xamarin Inc (http://www.xamarin.com).
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//
//
#if NET_4_0
using System.Collections.Generic;
namespace System.Threading.Tasks
{
interface IContinuation
{
void Execute ();
}
class TaskContinuation : IContinuation
{
readonly Task task;
readonly TaskContinuationOptions continuationOptions;
public TaskContinuation (Task task, TaskContinuationOptions continuationOptions)
{
this.task = task;
this.continuationOptions = continuationOptions;
}
bool ContinuationStatusCheck (TaskContinuationOptions kind)
{
if (kind == TaskContinuationOptions.None)
return true;
int kindCode = (int) kind;
var status = task.ContinuationAncestor.Status;
if (kindCode >= ((int) TaskContinuationOptions.NotOnRanToCompletion)) {
// Remove other options
kind &= ~(TaskContinuationOptions.PreferFairness
| TaskContinuationOptions.LongRunning
| TaskContinuationOptions.AttachedToParent
| TaskContinuationOptions.ExecuteSynchronously);
if (status == TaskStatus.Canceled) {
if (kind == TaskContinuationOptions.NotOnCanceled)
return false;
if (kind == TaskContinuationOptions.OnlyOnFaulted)
return false;
if (kind == TaskContinuationOptions.OnlyOnRanToCompletion)
return false;
} else if (status == TaskStatus.Faulted) {
if (kind == TaskContinuationOptions.NotOnFaulted)
return false;
if (kind == TaskContinuationOptions.OnlyOnCanceled)
return false;
if (kind == TaskContinuationOptions.OnlyOnRanToCompletion)
return false;
} else if (status == TaskStatus.RanToCompletion) {
if (kind == TaskContinuationOptions.NotOnRanToCompletion)
return false;
if (kind == TaskContinuationOptions.OnlyOnFaulted)
return false;
if (kind == TaskContinuationOptions.OnlyOnCanceled)
return false;
}
}
return true;
}
public void Execute ()
{
if (!ContinuationStatusCheck (continuationOptions)) {
task.CancelReal (notifyParent : true);
task.Dispose ();
return;
}
// The task may have been canceled externally
if (task.IsCompleted)
return;
if ((continuationOptions & TaskContinuationOptions.ExecuteSynchronously) != 0)
task.RunSynchronouslyCore (task.scheduler, false);
else
task.Schedule (false);
}
}
class AwaiterActionContinuation : IContinuation
{
readonly Action action;
public AwaiterActionContinuation (Action action)
{
this.action = action;
}
public void Execute ()
{
//
// Continuation can be inlined only when the current context allows it. This is different to awaiter setup
// because the context where the awaiter task is set to completed can be anywhere (due to TaskCompletionSource)
//
if ((SynchronizationContext.Current == null || SynchronizationContext.Current.GetType () == typeof (SynchronizationContext)) && TaskScheduler.IsDefault) {
action ();
} else {
ThreadPool.UnsafeQueueUserWorkItem (l => ((Action) l) (), action);
}
}
}
class SchedulerAwaitContinuation : IContinuation
{
readonly Task task;
public SchedulerAwaitContinuation (Task task)
{
this.task = task;
}
public void Execute ()
{
task.RunSynchronouslyCore (task.scheduler, true);
}
}
class SynchronizationContextContinuation : IContinuation
{
readonly Action action;
readonly SynchronizationContext ctx;
public SynchronizationContextContinuation (Action action, SynchronizationContext ctx)
{
this.action = action;
this.ctx = ctx;
}
public void Execute ()
{
// No context switch when we are on correct context
if (ctx == SynchronizationContext.Current)
action ();
else
ctx.Post (l => ((Action) l) (), action);
}
}
sealed class WhenAllContinuation : IContinuation
{
readonly Task owner;
readonly IList<Task> tasks;
int counter;
public WhenAllContinuation (Task owner, IList<Task> tasks)
{
this.owner = owner;
this.counter = tasks.Count;
this.tasks = tasks;
}
public void Execute ()
{
if (Interlocked.Decrement (ref counter) != 0)
return;
owner.Status = TaskStatus.Running;
bool canceled = false;
List<Exception> exceptions = null;
foreach (var task in tasks) {
if (task.IsFaulted) {
if (exceptions == null)
exceptions = new List<Exception> ();
exceptions.AddRange (task.Exception.InnerExceptions);
continue;
}
if (task.IsCanceled) {
canceled = true;
}
}
if (exceptions != null) {
owner.TrySetException (new AggregateException (exceptions), false, false);
return;
}
if (canceled) {
owner.CancelReal ();
return;
}
owner.Finish ();
}
}
sealed class WhenAllContinuation<TResult> : IContinuation
{
readonly Task<TResult[]> owner;
readonly IList<Task<TResult>> tasks;
int counter;
public WhenAllContinuation (Task<TResult[]> owner, IList<Task<TResult>> tasks)
{
this.owner = owner;
this.counter = tasks.Count;
this.tasks = tasks;
}
public void Execute ()
{
if (Interlocked.Decrement (ref counter) != 0)
return;
bool canceled = false;
List<Exception> exceptions = null;
TResult[] results = null;
for (int i = 0; i < tasks.Count; ++i) {
var task = tasks [i];
if (task.IsFaulted) {
if (exceptions == null)
exceptions = new List<Exception> ();
exceptions.AddRange (task.Exception.InnerExceptions);
continue;
}
if (task.IsCanceled) {
canceled = true;
continue;
}
if (results == null) {
if (canceled || exceptions != null)
continue;
results = new TResult[tasks.Count];
}
results[i] = task.Result;
}
if (exceptions != null) {
owner.TrySetException (new AggregateException (exceptions), false, false);
return;
}
if (canceled) {
owner.CancelReal ();
return;
}
owner.TrySetResult (results);
}
}
sealed class WhenAnyContinuation<T> : IContinuation where T : Task
{
readonly Task<T> owner;
readonly IList<T> tasks;
AtomicBooleanValue executed;
public WhenAnyContinuation (Task<T> owner, IList<T> tasks)
{
this.owner = owner;
this.tasks = tasks;
executed = new AtomicBooleanValue ();
}
public void Execute ()
{
if (!executed.TryRelaxedSet ())
return;
bool owner_notified = false;
for (int i = 0; i < tasks.Count; ++i) {
var task = tasks[i];
if (!task.IsCompleted) {
task.RemoveContinuation (this);
continue;
}
if (owner_notified)
continue;
owner.TrySetResult (task);
owner_notified = true;
}
}
}
sealed class ManualResetContinuation : IContinuation, IDisposable
{
readonly ManualResetEventSlim evt;
public ManualResetContinuation ()
{
this.evt = new ManualResetEventSlim ();
}
public ManualResetEventSlim Event {
get {
return evt;
}
}
public void Dispose ()
{
evt.Dispose ();
}
public void Execute ()
{
evt.Set ();
}
}
sealed class CountdownContinuation : IContinuation, IDisposable
{
readonly CountdownEvent evt;
bool disposed;
public CountdownContinuation (int initialCount)
{
this.evt = new CountdownEvent (initialCount);
}
public CountdownEvent Event {
get {
return evt;
}
}
public void Dispose ()
{
disposed = true;
Thread.MemoryBarrier ();
evt.Dispose ();
}
public void Execute ()
{
// Guard against possible race when continuation is disposed and some tasks may still
// execute it (removal was late and the execution is slower than the Dispose thread)
if (!disposed)
evt.Signal ();
}
}
sealed class DisposeContinuation : IContinuation
{
readonly IDisposable instance;
public DisposeContinuation (IDisposable instance)
{
this.instance = instance;
}
public void Execute ()
{
instance.Dispose ();
}
}
}
#endif

Some files were not shown because too many files have changed in this diff Show More