[Mono.Parallel] Removed broken Mono.Threading.Tasks code
authorAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 28 Apr 2014 16:17:22 +0000 (18:17 +0200)
committerAlexander Köplinger <alex.koeplinger@outlook.com>
Mon, 28 Apr 2014 16:17:22 +0000 (18:17 +0200)
The code in MonoTaskExtensions.cs relied on the internal method Execute(Action<Task>) in System.Threading.Tasks.Task which was removed in 0a66e60.

16 files changed:
mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/IMonoTaskScheduler.xml [deleted file]
mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/MonoTaskExtensions.xml [deleted file]
mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/ThreadWorker.xml [deleted file]
mcs/class/Mono.Parallel/Documentation/en/index.xml
mcs/class/Mono.Parallel/Mono.Parallel-net_4_0.csproj
mcs/class/Mono.Parallel/Mono.Parallel-net_4_5.csproj
mcs/class/Mono.Parallel/Mono.Parallel-tests-net_4_0.csproj
mcs/class/Mono.Parallel/Mono.Parallel-tests-net_4_5.csproj
mcs/class/Mono.Parallel/Mono.Parallel.dll.sources
mcs/class/Mono.Parallel/Mono.Parallel_test.dll.sources
mcs/class/Mono.Parallel/Mono.Threading.Tasks/FixedTaskScheduler.cs [deleted file]
mcs/class/Mono.Parallel/Mono.Threading.Tasks/MonoTaskExtensions.cs [deleted file]
mcs/class/Mono.Parallel/Mono.Threading.Tasks/MonoTaskScheduler.cs [deleted file]
mcs/class/Mono.Parallel/Mono.Threading.Tasks/ThreadWorker.cs [deleted file]
mcs/class/Mono.Parallel/Test/Mono.Threading.Tasks/MonoTaskExtensionsTests.cs [deleted file]
mcs/class/Mono.Parallel/Test/Mono.Threading.Tasks/MonoTaskSchedulerTests.cs [deleted file]

diff --git a/mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/IMonoTaskScheduler.xml b/mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/IMonoTaskScheduler.xml
deleted file mode 100644 (file)
index 7ea9123..0000000
+++ /dev/null
@@ -1,68 +0,0 @@
-<Type Name="IMonoTaskScheduler" FullName="Mono.Threading.Tasks.IMonoTaskScheduler">
-  <TypeSignature Language="C#" Value="public interface IMonoTaskScheduler" />
-  <TypeSignature Language="ILAsm" Value=".class public interface auto ansi abstract IMonoTaskScheduler" />
-  <AssemblyInfo>
-    <AssemblyName>Mono.Parallel</AssemblyName>
-    <AssemblyVersion>4.0.0.0</AssemblyVersion>
-  </AssemblyInfo>
-  <Interfaces />
-  <Docs>
-    <summary>The normal way to use another scheduler with ParalleFx is by creating a new type subclassing <see cref="T:System.Threading.Tasks.TaskScheduler" />. However Mono's ParallelFx has a few specifities which aren't captured by the base API. Developpers can thus also implement this interface with their custom scheduler for better Mono integration.</summary>
-    <remarks>The changes added by implementing this interface are totally non-breaking and the assembly will still work perfectly with .NET ParallelFx provided you implement correctly <see cref="T:System.Threading.Tasks.TaskScheduler" /> correctly.</remarks>
-  </Docs>
-  <Members>
-    <Member MemberName="ParticipateUntil">
-      <MemberSignature Language="C#" Value="public void ParticipateUntil (System.Threading.Tasks.Task task);" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void ParticipateUntil(class System.Threading.Tasks.Task task) cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters>
-        <Parameter Name="task" Type="System.Threading.Tasks.Task" />
-      </Parameters>
-      <Docs>
-        <param name="task">The task to wait on.</param>
-        <summary>This method will be called when a thread decides to wait on a task completion. Developpers are free to simply wait on the supplied Task or provide a smarter cooperative waiting mechanism.</summary>
-        <remarks>A simple waiting mechanism can be achieved via the following pattern:
-
-<example><code lang="C#">
-public void PartiticipateUntil (Task task)
-{
-       ManualResetEventSlim evt = new ManualResetEventSlim (false);
-       task.ContinueWith (_ =&gt; evt.Set (), TaskContinuationOptions.ExecuteSynchronously);
-       evt.Wait ();
-}
-  </code></example></remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="ParticipateUntil">
-      <MemberSignature Language="C#" Value="public bool ParticipateUntil (System.Threading.Tasks.Task task, System.Threading.ManualResetEventSlim predicateEvt, int millisecondsTimeout);" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool ParticipateUntil(class System.Threading.Tasks.Task task, class System.Threading.ManualResetEventSlim predicateEvt, int32 millisecondsTimeout) cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Boolean</ReturnType>
-      </ReturnValue>
-      <Parameters>
-        <Parameter Name="task" Type="System.Threading.Tasks.Task" />
-        <Parameter Name="predicateEvt" Type="System.Threading.ManualResetEventSlim" />
-        <Parameter Name="millisecondsTimeout" Type="System.Int32" />
-      </Parameters>
-      <Docs>
-        <param name="task">Task to wait on.</param>
-        <param name="predicateEvt">Additional preemptive conditions for stopping the waiting.</param>
-        <param name="millisecondsTimeout">An countdown specifying the maximum amount of time the method can last before returning.</param>
-        <summary>This method will be called when a thread decides to wait on a task completion or a set of condition summarized via the given <see cref="T:System.Threading.ManualResetEventSlim" />. Developpers are free to simply wait on the supplied Task/event or provide a smarter cooperative waiting mechanism.</summary>
-        <returns>
-          <see langword="true" /> if the method returns because of either event was set or timeout was reached, <see langword="false" /> if the task completed.</returns>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-  </Members>
-</Type>
diff --git a/mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/MonoTaskExtensions.xml b/mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/MonoTaskExtensions.xml
deleted file mode 100644 (file)
index f11a56c..0000000
+++ /dev/null
@@ -1,53 +0,0 @@
-<Type Name="MonoTaskExtensions" FullName="Mono.Threading.Tasks.MonoTaskExtensions">
-  <TypeSignature Language="C#" Value="public static class MonoTaskExtensions" />
-  <TypeSignature Language="ILAsm" Value=".class public auto ansi abstract sealed MonoTaskExtensions extends System.Object" />
-  <AssemblyInfo>
-    <AssemblyName>Mono.Parallel</AssemblyName>
-    <AssemblyVersion>4.0.0.0</AssemblyVersion>
-  </AssemblyInfo>
-  <Base>
-    <BaseTypeName>System.Object</BaseTypeName>
-  </Base>
-  <Interfaces />
-  <Docs>
-    <summary>Provide public wrappers around internal methods used in Mono implementation of <see cref="T:System.Threading.Tasks.Task" /> type.</summary>
-    <remarks>These extensions are targeted at developers coding custom schedulers so that they can tap into the specificities of the Mono implementation.</remarks>
-  </Docs>
-  <Members>
-    <Member MemberName="Execute">
-      <MemberSignature Language="C#" Value="public static void Execute (this System.Threading.Tasks.Task task, Action&lt;System.Threading.Tasks.Task&gt; childWorkAdder);" />
-      <MemberSignature Language="ILAsm" Value=".method public static hidebysig void Execute(class System.Threading.Tasks.Task task, class System.Action`1&lt;class System.Threading.Tasks.Task&gt; childWorkAdder) cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters>
-        <Parameter Name="task" Type="System.Threading.Tasks.Task" RefType="this" />
-        <Parameter Name="childWorkAdder" Type="System.Action&lt;System.Threading.Tasks.Task&gt;" />
-      </Parameters>
-      <Docs>
-        <param name="task">Task to run.</param>
-        <param name="childWorkAdder">Action that will be called with the Task that is being scheduled while above Task is executed as a parameter.</param>
-        <summary>Execute a <see cref="T:System.Threading.Tasks.Task" /> body and track any other Task scheduling during it which is then passed to the supplied action for specific scheduling.</summary>
-        <remarks>
-          <block subset="none" type="note">
-            <para>
-       If the inner Task that is scheduled has been created with TaskCreationOptions.PreferFairness, the supplied action won't be called and instead the Task will be scheduled normally on the current <see cref="T:System.Threading.Tasks.TaskScheduler" /></para>
-          </block>
-
-The following example retrieve a task from a local deque, execute it and add any eventual child Task created/scheduled to its local deque using PushBottom (safe since we are on the same thread the whole time).
-
-<example><code lang="C#">
-       Task task;
-       IConcurrentDeque&lt;Task&gt; deque = new CyclicDeque&lt;Task&gt; ();
-
-       if (deque.PopBottom (out task) == PopResult.Succeed))
-               task.Execute (deque.PushBottom);
-  </code></example></remarks>
-      </Docs>
-    </Member>
-  </Members>
-</Type>
diff --git a/mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/ThreadWorker.xml b/mcs/class/Mono.Parallel/Documentation/en/Mono.Threading.Tasks/ThreadWorker.xml
deleted file mode 100644 (file)
index 0063297..0000000
+++ /dev/null
@@ -1,351 +0,0 @@
-<Type Name="ThreadWorker" FullName="Mono.Threading.Tasks.ThreadWorker">
-  <TypeSignature Language="C#" Value="public class ThreadWorker : IDisposable" />
-  <TypeSignature Language="ILAsm" Value=".class public auto ansi beforefieldinit ThreadWorker extends System.Object implements class System.IDisposable" />
-  <AssemblyInfo>
-    <AssemblyName>Mono.Parallel</AssemblyName>
-    <AssemblyVersion>4.0.0.0</AssemblyVersion>
-  </AssemblyInfo>
-  <Base>
-    <BaseTypeName>System.Object</BaseTypeName>
-  </Base>
-  <Interfaces>
-    <Interface>
-      <InterfaceName>System.IDisposable</InterfaceName>
-    </Interface>
-  </Interfaces>
-  <Docs>
-    <summary>This class wraps a <see cref="T:System.Threading.Thread" /> to provide a suitable ParallelFx worker (i.e. something that process <see cref="T:System.Threading.Tasks.Task" />).</summary>
-    <remarks>To be added.</remarks>
-  </Docs>
-  <Members>
-    <Member MemberName=".ctor">
-      <MemberSignature Language="C#" Value="public ThreadWorker (Mono.Threading.Tasks.ThreadWorker[] others, int workerPosition, System.Collections.Concurrent.IProducerConsumerCollection&lt;System.Threading.Tasks.Task&gt; sharedWorkQueue, Mono.Threading.Tasks.IConcurrentDeque&lt;System.Threading.Tasks.Task&gt; dDeque, System.Threading.ThreadPriority priority, System.Threading.ManualResetEvent handle);" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig specialname rtspecialname instance void .ctor(class Mono.Threading.Tasks.ThreadWorker[] others, int32 workerPosition, class System.Collections.Concurrent.IProducerConsumerCollection`1&lt;class System.Threading.Tasks.Task&gt; sharedWorkQueue, class Mono.Threading.Tasks.IConcurrentDeque`1&lt;class System.Threading.Tasks.Task&gt; dDeque, valuetype System.Threading.ThreadPriority priority, class System.Threading.ManualResetEvent handle) cil managed" />
-      <MemberType>Constructor</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <Parameters>
-        <Parameter Name="others" Type="Mono.Threading.Tasks.ThreadWorker[]" />
-        <Parameter Name="workerPosition" Type="System.Int32" />
-        <Parameter Name="sharedWorkQueue" Type="System.Collections.Concurrent.IProducerConsumerCollection&lt;System.Threading.Tasks.Task&gt;" />
-        <Parameter Name="dDeque" Type="Mono.Threading.Tasks.IConcurrentDeque&lt;System.Threading.Tasks.Task&gt;" />
-        <Parameter Name="priority" Type="System.Threading.ThreadPriority" />
-        <Parameter Name="handle" Type="System.Threading.ManualResetEvent" />
-      </Parameters>
-      <Docs>
-        <param name="others">This is an array containing all other workers created. It's necessary if you want worker cooperating together for getting extra work.</param>
-        <param name="workerPosition">The position in the previous array where this worker will be placed.</param>
-        <param name="sharedWorkQueue">This is the global data structures that holds the Task when the system starts and is not yet bootstraped. It's also where tasks end up if they are executed with fairness enabled.</param>
-        <param name="dDeque">The personnal instance of a deque type used by the worker when storing the tasks its responsible of and letting other workers retrieve them.</param>
-        <param name="priority">The priority of the underlying thread.</param>
-        <param name="handle">This is a handle shared (ideally) by all workers to synchronize and deep sleep when there is no more work to do. Setting the handle will wake them up.</param>
-        <summary>Build a new worker instance.</summary>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="AutoReference">
-      <MemberSignature Language="C#" Value="public static Mono.Threading.Tasks.ThreadWorker AutoReference { get; set; }" />
-      <MemberSignature Language="ILAsm" Value=".property class Mono.Threading.Tasks.ThreadWorker AutoReference" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>Mono.Threading.Tasks.ThreadWorker</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>This [ThreadStatic] field is automatically updated when WorkerMethod method run so that you can check if you are making a re-entrant call on the same thread.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="ChildWorkAdder">
-      <MemberSignature Language="C#" Value="protected virtual void ChildWorkAdder (System.Threading.Tasks.Task t);" />
-      <MemberSignature Language="ILAsm" Value=".method familyorassemblyhidebysig newslot virtual instance void ChildWorkAdder(class System.Threading.Tasks.Task t) cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters>
-        <Parameter Name="t" Type="System.Threading.Tasks.Task" />
-      </Parameters>
-      <Docs>
-        <param name="t">Task being scheduled</param>
-        <summary>This method is called when the currently executing Task tries to schedule another Task as part of its computation. This method allows to redirect the scheduling to a specific place.</summary>
-        <remarks>By default the supplied task is added to the ThreadWorker deque via the PushBottom operation.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Deque">
-      <MemberSignature Language="C#" Value="protected Mono.Threading.Tasks.IConcurrentDeque&lt;System.Threading.Tasks.Task&gt; Deque { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance class Mono.Threading.Tasks.IConcurrentDeque`1&lt;class System.Threading.Tasks.Task&gt; Deque" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>Mono.Threading.Tasks.IConcurrentDeque&lt;System.Threading.Tasks.Task&gt;</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>Allow access to the <see cref="T:Mono.Threading.Tasks.IConcurrentDeque&lt;T&gt;" /> used by the ThreadWorker.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Dispose">
-      <MemberSignature Language="C#" Value="public virtual void Dispose ();" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Dispose() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>To be added.</summary>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Equals">
-      <MemberSignature Language="C#" Value="public virtual bool Equals (Mono.Threading.Tasks.ThreadWorker other);" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance bool Equals(class Mono.Threading.Tasks.ThreadWorker other) cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Boolean</ReturnType>
-      </ReturnValue>
-      <Parameters>
-        <Parameter Name="other" Type="Mono.Threading.Tasks.ThreadWorker" />
-      </Parameters>
-      <Docs>
-        <param name="other">To be added.</param>
-        <summary>To be added.</summary>
-        <returns>To be added.</returns>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Equals">
-      <MemberSignature Language="C#" Value="public override bool Equals (object obj);" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance bool Equals(object obj) cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Boolean</ReturnType>
-      </ReturnValue>
-      <Parameters>
-        <Parameter Name="obj" Type="System.Object" />
-      </Parameters>
-      <Docs>
-        <param name="obj">To be added.</param>
-        <summary>To be added.</summary>
-        <returns>To be added.</returns>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Finished">
-      <MemberSignature Language="C#" Value="public bool Finished { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance bool Finished" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Boolean</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>Tells if the underlying thread has exited or not.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="GetHashCode">
-      <MemberSignature Language="C#" Value="public override int GetHashCode ();" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig virtual instance int32 GetHashCode() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Int32</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>To be added.</summary>
-        <returns>To be added.</returns>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Id">
-      <MemberSignature Language="C#" Value="public int Id { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance int32 Id" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Int32</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>Return the Id of the underlying thread used by the ThreadWorker.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="InitializeUnderlyingThread">
-      <MemberSignature Language="C#" Value="protected virtual void InitializeUnderlyingThread ();" />
-      <MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void InitializeUnderlyingThread() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>To be added.</summary>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Others">
-      <MemberSignature Language="C#" Value="protected Mono.Threading.Tasks.ThreadWorker[] Others { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance class Mono.Threading.Tasks.ThreadWorker[] Others" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>Mono.Threading.Tasks.ThreadWorker[]</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>Returns the array of existing ThreadWorker that been initially supplied.</summary>
-        <value>To be added.</value>
-        <remarks>If you are iterating the array, make sure you skip the current instance of ThreadWorker with value of <see cref="P:Mono.Threading.Tasks.ThreadWorker.WorkerPosition" /></remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Priority">
-      <MemberSignature Language="C#" Value="protected System.Threading.ThreadPriority Priority { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance valuetype System.Threading.ThreadPriority Priority" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Threading.ThreadPriority</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>The priority the underlying thread is running with.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Pulse">
-      <MemberSignature Language="C#" Value="public virtual void Pulse ();" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Pulse() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>To be added.</summary>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="Stop">
-      <MemberSignature Language="C#" Value="public virtual void Stop ();" />
-      <MemberSignature Language="ILAsm" Value=".method public hidebysig newslot virtual instance void Stop() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>Stop the underlying thread of this ThreadWorker.</summary>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="WaitHandle">
-      <MemberSignature Language="C#" Value="protected System.Threading.ManualResetEvent WaitHandle { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance class System.Threading.ManualResetEvent WaitHandle" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Threading.ManualResetEvent</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>Acces the WaitHandle normally shared by all your ThreadWorker instances to deep sleep or otherwise synchronize on.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="WorkerMethod">
-      <MemberSignature Language="C#" Value="protected virtual bool WorkerMethod ();" />
-      <MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance bool WorkerMethod() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Boolean</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>This is the method executed by WorkerMethod to do the actual processing of tasks.</summary>
-        <returns>
-          <see langword="true" /> if the method processed a <see cref="T:System.Threading.Tasks.Task" /> while it ran, <see langword="false" /> otherwise.</returns>
-        <remarks>By default this method applies the following algorithm:
-<list type="bullet"><item><term>Check if the global data structures contains task and fetch as much as possible into its own deque</term></item><item><term>Execute whatever its deque contains</term></item><item><term>Do a couple of pass over the other workers to try to steal some work to do</term></item></list></remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="WorkerMethodWrapper">
-      <MemberSignature Language="C#" Value="protected virtual void WorkerMethodWrapper ();" />
-      <MemberSignature Language="ILAsm" Value=".method familyhidebysig newslot virtual instance void WorkerMethodWrapper() cil managed" />
-      <MemberType>Method</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Void</ReturnType>
-      </ReturnValue>
-      <Parameters />
-      <Docs>
-        <summary>This is the method executed by the underlying thread.</summary>
-        <remarks>By default this method consists of a while loop calling repeatedly <see cref="M:Mono.Threading.Tasks.ThreadWorker.WorkerMethodWrapper()" /> and sleeping accordingly when there is no more work to do.</remarks>
-      </Docs>
-    </Member>
-    <Member MemberName="WorkerPosition">
-      <MemberSignature Language="C#" Value="protected int WorkerPosition { get; }" />
-      <MemberSignature Language="ILAsm" Value=".property instance int32 WorkerPosition" />
-      <MemberType>Property</MemberType>
-      <AssemblyInfo>
-        <AssemblyVersion>4.0.0.0</AssemblyVersion>
-      </AssemblyInfo>
-      <ReturnValue>
-        <ReturnType>System.Int32</ReturnType>
-      </ReturnValue>
-      <Docs>
-        <summary>Position of the current instance in the <see cref="P:Mono.Threading.Tasks.ThreadWorker.Others" /> array.</summary>
-        <value>To be added.</value>
-        <remarks>To be added.</remarks>
-      </Docs>
-    </Member>
-  </Members>
-</Type>
index ab8e4e299475db81f4b6a67de52c7dc81f9ce902..6739a805613cd76aea79f0b047bf833dedb05a3d 100644 (file)
     <Namespace Name="Mono.Threading.Tasks">
       <Type Name="CyclicDeque`1" DisplayName="CyclicDeque&lt;T&gt;" Kind="Class" />
       <Type Name="IConcurrentDeque`1" DisplayName="IConcurrentDeque&lt;T&gt;" Kind="Interface" />
-      <Type Name="IMonoTaskScheduler" Kind="Interface" />
-      <Type Name="MonoTaskExtensions" Kind="Class" />
       <Type Name="PopResult" Kind="Enumeration" />
-      <Type Name="ThreadWorker" Kind="Class" />
     </Namespace>
   </Types>
   <Title>Mono.Parallel</Title>
-  <ExtensionMethods>
-    <ExtensionMethod>
-      <Targets>
-        <Target Type="T:System.Threading.Tasks.Task" />
-      </Targets>
-      <Member MemberName="Execute">
-        <MemberSignature Language="C#" Value="public static void Execute (this System.Threading.Tasks.Task task, Action&lt;System.Threading.Tasks.Task&gt; childWorkAdder);" />
-        <MemberSignature Language="ILAsm" Value=".method public static hidebysig void Execute(class System.Threading.Tasks.Task task, class System.Action`1&lt;class System.Threading.Tasks.Task&gt; childWorkAdder) cil managed" />
-        <MemberType>ExtensionMethod</MemberType>
-        <ReturnValue>
-          <ReturnType>System.Void</ReturnType>
-        </ReturnValue>
-        <Parameters>
-          <Parameter Name="task" Type="System.Threading.Tasks.Task" RefType="this" />
-          <Parameter Name="childWorkAdder" Type="System.Action&lt;System.Threading.Tasks.Task&gt;" />
-        </Parameters>
-        <Docs>
-          <param name="task">Task to run.</param>
-          <param name="childWorkAdder">Action that will be called with the Task that is being scheduled while above Task is executed as a parameter.</param>
-          <summary>Execute a <see cref="T:System.Threading.Tasks.Task" /> body and track any other Task scheduling during it which is then passed to the supplied action for specific scheduling.</summary>
-        </Docs>
-        <Link Type="Mono.Threading.Tasks.MonoTaskExtensions" Member="M:Mono.Threading.Tasks.MonoTaskExtensions.Execute(System.Threading.Tasks.Task,System.Action{System.Threading.Tasks.Task})" />
-      </Member>
-    </ExtensionMethod>
-  </ExtensionMethods>
 </Overview>
index 32e4b884550a873c91c4d75311b8f34483f69ebe..ea5494f2652f87d36fcc151f31c7a2620c8abca2 100644 (file)
     <Compile Include="..\corlib\System.Threading\AtomicBoolean.cs" />\r
     <Compile Include="Assembly\AssemblyInfo.cs" />\r
     <Compile Include="Mono.Collections.Concurrent\ConcurrentSkipList.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\FixedTaskScheduler.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\MonoTaskExtensions.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\MonoTaskScheduler.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\ThreadWorker.cs" />\r
     <Compile Include="Mono.Threading\CSnzi.cs" />\r
     <Compile Include="Mono.Threading\ReaderWriterLockSlimmer.cs" />\r
     <Compile Include="Mono.Threading\Snzi.cs" />\r
index c9eb62d3de2e6974a3232eaec6a20dae5bc07a64..247abf941d3f9d1681990dafbe18cdd1af32c97e 100644 (file)
     <Compile Include="..\corlib\System.Threading\AtomicBoolean.cs" />\r
     <Compile Include="Assembly\AssemblyInfo.cs" />\r
     <Compile Include="Mono.Collections.Concurrent\ConcurrentSkipList.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\FixedTaskScheduler.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\MonoTaskExtensions.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\MonoTaskScheduler.cs" />\r
-    <Compile Include="Mono.Threading.Tasks\ThreadWorker.cs" />\r
     <Compile Include="Mono.Threading\CSnzi.cs" />\r
     <Compile Include="Mono.Threading\ReaderWriterLockSlimmer.cs" />\r
     <Compile Include="Mono.Threading\Snzi.cs" />\r
index 1f3081a8ae93fdc38751180c6dd1a93e25103a5a..28b7af76fa1dfbd38eb2622a25f17e8e1ada2f5d 100644 (file)
@@ -46,8 +46,6 @@
   <ItemGroup>\r
     <Compile Include="Test\Mono.Collections.Concurrent\CollectionStressTestHelper.cs" />\r
     <Compile Include="Test\Mono.Collections.Concurrent\ConcurrentSkipListTests.cs" />\r
-    <Compile Include="Test\Mono.Threading.Tasks\MonoTaskExtensionsTests.cs" />\r
-    <Compile Include="Test\Mono.Threading.Tasks\MonoTaskSchedulerTests.cs" />\r
     <Compile Include="Test\Mono.Threading\ParallelTestHelper.cs" />\r
     <Compile Include="Test\Mono.Threading\SnziTests.cs" />\r  </ItemGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
index 4b4dd8ee8000f81a15bdccc02da8aaffc8ab6261..837a9e3b6df48935dea5836776fc06e09982840a 100644 (file)
@@ -46,8 +46,6 @@
   <ItemGroup>\r
     <Compile Include="Test\Mono.Collections.Concurrent\CollectionStressTestHelper.cs" />\r
     <Compile Include="Test\Mono.Collections.Concurrent\ConcurrentSkipListTests.cs" />\r
-    <Compile Include="Test\Mono.Threading.Tasks\MonoTaskExtensionsTests.cs" />\r
-    <Compile Include="Test\Mono.Threading.Tasks\MonoTaskSchedulerTests.cs" />\r
     <Compile Include="Test\Mono.Threading\ParallelTestHelper.cs" />\r
     <Compile Include="Test\Mono.Threading\SnziTests.cs" />\r  </ItemGroup>\r
   <!-- To modify your build process, add your task inside one of the targets below and uncomment it. \r
index 31f320c2ce8f30469d315a27345a3c0e8eb56054..57ec8a4604adb5df29510703824f95278a0572a7 100644 (file)
@@ -11,7 +11,3 @@ Mono.Threading/ReaderWriterLockSlimmer.cs
 ../corlib/System.Threading.Tasks/CyclicDeque.cs
 ../corlib/System.Threading.Tasks/IConcurrentDeque.cs
 ../corlib/System.Threading.Tasks/PopResult.cs
-Mono.Threading.Tasks/ThreadWorker.cs
-Mono.Threading.Tasks/MonoTaskExtensions.cs
-Mono.Threading.Tasks/MonoTaskScheduler.cs
-Mono.Threading.Tasks/FixedTaskScheduler.cs
index 19baf2d77430d96fbe9f0e8feaa5f9028ebcc448..1eb8276dbde5a7eae4bf842def1b68edff5afaea 100644 (file)
@@ -2,5 +2,3 @@ Mono.Collections.Concurrent/CollectionStressTestHelper.cs
 Mono.Collections.Concurrent/ConcurrentSkipListTests.cs
 Mono.Threading/ParallelTestHelper.cs
 Mono.Threading/SnziTests.cs
-Mono.Threading.Tasks/MonoTaskExtensionsTests.cs
-Mono.Threading.Tasks/MonoTaskSchedulerTests.cs
diff --git a/mcs/class/Mono.Parallel/Mono.Threading.Tasks/FixedTaskScheduler.cs b/mcs/class/Mono.Parallel/Mono.Threading.Tasks/FixedTaskScheduler.cs
deleted file mode 100644 (file)
index da656a5..0000000
+++ /dev/null
@@ -1,139 +0,0 @@
-// Scheduler.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;
-using System.Threading.Tasks;
-using System.Collections.Concurrent;
-
-namespace Mono.Threading.Tasks
-{
-       public class FixedTaskScheduler: TaskScheduler, IMonoTaskScheduler
-       {
-               readonly IProducerConsumerCollection<Task> workQueue;
-               readonly ThreadWorker[]        workers;
-               readonly ManualResetEvent      pulseHandle = new ManualResetEvent (false);
-
-               public FixedTaskScheduler ()
-                       : this (Environment.ProcessorCount, ThreadPriority.Normal)
-               {
-                       
-               }
-               
-               public FixedTaskScheduler (int maxWorker, ThreadPriority priority)
-               {
-                       workQueue = new ConcurrentQueue<Task> ();
-                       workers = new ThreadWorker [maxWorker];
-                       
-                       for (int i = 0; i < maxWorker; i++) {
-                               workers [i] = new ThreadWorker (workers, i, workQueue, new CyclicDeque<Task> (), priority, pulseHandle);
-                               workers [i].Pulse ();
-                       }
-               }
-
-               protected override void QueueTask (Task t)
-               {
-                       // Add to the shared work pool
-                       workQueue.TryAdd (t);
-                       // Wake up some worker if they were asleep
-                       PulseAll ();
-               }
-
-               public void MonoParticipateUntil (Task task)
-               {
-                       if (task.IsCompleted)
-                               return;
-
-                       ManualResetEventSlim evt = new ManualResetEventSlim (false);
-                       task.ContinueWith (_ => evt.Set (), TaskContinuationOptions.ExecuteSynchronously);
-                       if (evt.IsSet || task.IsCompleted)
-                               return;
-                       
-                       ParticipateUntilInternal (task, evt, -1);
-               }
-               
-               public bool MonoParticipateUntil (Task task, ManualResetEventSlim evt, int millisecondsTimeout)
-               {
-                       if (task.IsCompleted)
-                               return false;
-
-                       bool isFromPredicate = true;
-                       task.ContinueWith (_ => { isFromPredicate = false; evt.Set (); }, TaskContinuationOptions.ExecuteSynchronously);
-
-                       ParticipateUntilInternal (task, evt, millisecondsTimeout);
-
-                       if (task.IsCompleted)
-                               return false;
-
-                       return isFromPredicate;
-               }
-               
-               public void ParticipateUntilInternal (Task self, ManualResetEventSlim evt, int millisecondsTimeout)
-               {
-                       ThreadWorker.ParticipativeWorkerMethod (self, evt, millisecondsTimeout, workQueue, workers, pulseHandle, (a, b) => true);
-               }
-
-               static bool TaskCompletedPredicate (Task self)
-               {
-                       return self.IsCompleted;
-               }
-               
-               public void PulseAll ()
-               {
-                       pulseHandle.Set ();
-               }
-               
-               public void Dispose ()
-               {
-                       foreach (ThreadWorker w in workers)
-                               w.Dispose ();
-               }
-
-               #region Scheduler dummy stubs
-               protected override System.Collections.Generic.IEnumerable<Task> GetScheduledTasks ()
-               {
-                       throw new System.NotImplementedException();
-               }
-
-               protected override bool TryDequeue (Task task)
-               {
-                       throw new System.NotImplementedException();
-               }
-
-               protected override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
-               {
-                       task.Execute (null);
-                       return true;
-               }
-               
-               public override int MaximumConcurrencyLevel {
-                       get {
-                               return base.MaximumConcurrencyLevel;
-                       }
-               }
-               #endregion
-       }
-}
-#endif
diff --git a/mcs/class/Mono.Parallel/Mono.Threading.Tasks/MonoTaskExtensions.cs b/mcs/class/Mono.Parallel/Mono.Threading.Tasks/MonoTaskExtensions.cs
deleted file mode 100644 (file)
index 1b52857..0000000
+++ /dev/null
@@ -1,54 +0,0 @@
-// 
-// MonoTaskExtensions.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.Threading.Tasks;
-using System.Reflection;
-
-namespace Mono.Threading.Tasks
-{
-       public static class MonoTaskExtensions
-       {
-               readonly static Action<Task, Action<Task>> internalExecute = null;
-
-               static MonoTaskExtensions ()
-               {
-                       // Initialize internal execute
-                       var method = typeof(Task).GetMethod ("Execute", BindingFlags.Instance | BindingFlags.NonPublic);
-                       internalExecute = (Action<Task, Action<Task>>)Delegate.CreateDelegate (typeof(Action<Task, Action<Task>>), method);
-               }
-
-               // Allow external worker to call into the otherwise internal corresponding method of Task
-               public static void Execute (this Task task, Action<Task> childWorkAdder)
-               {
-                       internalExecute (task, childWorkAdder);
-               }
-       }
-}
-
-#endif
diff --git a/mcs/class/Mono.Parallel/Mono.Threading.Tasks/MonoTaskScheduler.cs b/mcs/class/Mono.Parallel/Mono.Threading.Tasks/MonoTaskScheduler.cs
deleted file mode 100644 (file)
index a21c323..0000000
+++ /dev/null
@@ -1,42 +0,0 @@
-// 
-// MonoTaskScheduler.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.Threading;
-using System.Threading.Tasks;
-
-namespace Mono.Threading.Tasks
-{
-       public interface IMonoTaskScheduler
-       {
-               void MonoParticipateUntil (Task task);
-               bool MonoParticipateUntil (Task task, ManualResetEventSlim predicateEvt, int millisecondsTimeout);
-       }
-}
-
-#endif
diff --git a/mcs/class/Mono.Parallel/Mono.Threading.Tasks/ThreadWorker.cs b/mcs/class/Mono.Parallel/Mono.Threading.Tasks/ThreadWorker.cs
deleted file mode 100644 (file)
index 575763c..0000000
+++ /dev/null
@@ -1,421 +0,0 @@
-// ThreadWorker.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;
-using System.Collections.Concurrent;
-using System.Threading.Tasks;
-using Watch = System.Diagnostics.Stopwatch;
-
-namespace Mono.Threading.Tasks
-{
-       public class ThreadWorker : IDisposable
-       {
-               Thread workerThread;
-
-               /* This field is used when a TheadWorker have to call Task.Wait
-                * which bring him back here with the static WorkerMethod although
-                * it's more optimized for him to continue calling its own WorkerMethod
-                */
-               [ThreadStatic]
-               static ThreadWorker autoReference;
-               
-               readonly IConcurrentDeque<Task> dDeque;
-               readonly ThreadWorker[]         others;
-               readonly ManualResetEvent       waitHandle;
-               readonly IProducerConsumerCollection<Task> sharedWorkQueue;
-               readonly ThreadPriority         threadPriority;
-
-               // Flag to tell if workerThread is running
-               int started = 0; 
-               
-               readonly int  workerLength;
-               readonly int  workerPosition;
-               const    int  maxRetry = 3;
-               
-               const int sleepThreshold = 100;
-               int deepSleepTime = 8;
-               readonly Action<Task> adder;
-
-               Task currentTask;
-               
-               public ThreadWorker (ThreadWorker[] others,
-                                    int workerPosition,
-                                    IProducerConsumerCollection<Task> sharedWorkQueue,
-                                    IConcurrentDeque<Task> dDeque,
-                                    ThreadPriority priority,
-                                    ManualResetEvent handle)
-               {
-                       this.others          = others;
-                       this.dDeque          = dDeque;
-                       this.sharedWorkQueue = sharedWorkQueue;
-                       this.workerLength    = others.Length;
-                       this.workerPosition  = workerPosition;
-                       this.waitHandle      = handle;
-                       this.threadPriority  = priority;
-                       this.adder           = new Action<Task> (ChildWorkAdder);
-
-                       InitializeUnderlyingThread ();
-               }
-
-               protected virtual void InitializeUnderlyingThread ()
-               {
-                       this.workerThread = new Thread (WorkerMethodWrapper);
-       
-                       this.workerThread.IsBackground = true;
-                       this.workerThread.Priority = threadPriority;
-                       this.workerThread.Name = "ParallelFxThreadWorker";
-               }
-
-               public virtual void Dispose ()
-               {
-                       Stop ();
-                       if (workerThread.ThreadState != ThreadState.Stopped)
-                               workerThread.Abort ();
-               }
-
-               public virtual void Pulse ()
-               {
-                       if (started == 1)
-                               return;
-
-                       // If the thread was stopped then set it in use and restart it
-                       int result = Interlocked.Exchange (ref started, 1);
-                       if (result != 0)
-                               return;
-
-                       if (this.workerThread.ThreadState != ThreadState.Unstarted) {
-                               InitializeUnderlyingThread ();
-                       }
-
-                       workerThread.Start ();
-               }
-
-               public virtual void Stop ()
-               {
-                       // Set the flag to stop so that the while in the thread will stop
-                       // doing its infinite loop.
-                       started = 0;
-               }
-
-               // This is the actual method called in the Thread
-               protected virtual void WorkerMethodWrapper ()
-               {
-                       int sleepTime = 0;
-                       autoReference = this;
-                       bool wasWokenUp = false;
-                       
-                       // Main loop
-                       while (started == 1) {
-                               bool result = false;
-
-                               result = WorkerMethod ();
-                               if (!result && wasWokenUp)
-                                       waitHandle.Reset ();
-                               wasWokenUp = false;
-
-                               Thread.Yield ();
-
-                               if (result) {
-                                       deepSleepTime = 8;
-                                       sleepTime = 0;
-                                       continue;
-                               }
-
-                               // If we are spinning too much, have a deeper sleep
-                               if (++sleepTime > sleepThreshold && sharedWorkQueue.Count == 0) {
-                                       wasWokenUp = waitHandle.WaitOne ((deepSleepTime = deepSleepTime >= 0x4000 ? 0x4000 : deepSleepTime << 1));
-                               }
-                       }
-
-                       started = 0;
-               }
-
-               // Main method, used to do all the logic of retrieving, processing and stealing work.
-               protected virtual bool WorkerMethod ()
-               {
-                       bool result = false;
-                       bool hasStolenFromOther;
-
-                       do {
-                               hasStolenFromOther = false;
-                               
-                               Task value;
-                               
-                               // We fill up our work deque concurrently with other ThreadWorker
-                               while (sharedWorkQueue.Count > 0) {
-                                       waitHandle.Set ();
-
-                                       while (sharedWorkQueue.TryTake (out value)) {
-                                               dDeque.PushBottom (value);
-                                       }
-
-                                       // Now we process our work
-                                       while (dDeque.PopBottom (out value) == PopResult.Succeed) {
-                                               waitHandle.Set ();
-                                               ExecuteTask (value, ref result);
-                                       }
-                               }
-
-                               // When we have finished, steal from other worker
-                               ThreadWorker other;
-                               
-                               // Repeat the operation a little so that we can let other things process.
-                               for (int j = 0; j < maxRetry; ++j) {
-                                       int len = workerLength + workerPosition;
-                                       // Start stealing with the ThreadWorker at our right to minimize contention
-                                       for (int it = workerPosition + 1; it < len; ++it) {
-                                               int i = it % workerLength;
-                                               if ((other = others [i]) == null || other == this)
-                                                       continue;
-                                               
-                                               // Maybe make this steal more than one item at a time, see TODO.
-                                               while (other.dDeque.PopTop (out value) == PopResult.Succeed) {
-                                                       if (!hasStolenFromOther)
-                                                               waitHandle.Set ();
-
-                                                       hasStolenFromOther = true;
-                                                       ExecuteTask (value, ref result);
-                                               }
-                                       }
-                               }
-                       } while (sharedWorkQueue.Count > 0 || hasStolenFromOther);
-                       
-                       return result;
-               }
-
-               void ExecuteTask (Task value, ref bool result)
-               {
-                       if (value == null)
-                               return;
-
-                       var saveCurrent = currentTask;
-                       currentTask = value;
-                       value.Execute (adder);
-                       result = true;
-                       currentTask = saveCurrent;
-               }
-
-               // Almost same as above but with an added predicate and treating one item at a time. 
-               // It's used by Scheduler Participate(...) method for special waiting case like
-               // Task.WaitAll(someTasks) or Task.WaitAny(someTasks)
-               // Predicate should be really fast and not blocking as it is called a good deal of time
-               // Also, the method skip tasks that are LongRunning to avoid blocking (Task are not LongRunning by default)
-               public static void ParticipativeWorkerMethod (Task self,
-                                                             ManualResetEventSlim predicateEvt,
-                                                             int millisecondsTimeout,
-                                                             IProducerConsumerCollection<Task> sharedWorkQueue,
-                                                             ThreadWorker[] others,
-                                                             ManualResetEvent evt,
-                                                             Func<Task, Task, bool> checkTaskFitness)
-               {
-                       const int stage1 = 5, stage2 = 0;
-                       int tries = 50;
-                       WaitHandle[] handles = null;
-                       Watch watch = Watch.StartNew ();
-                       if (millisecondsTimeout == -1)
-                               millisecondsTimeout = int.MaxValue;
-                       bool aggressive = false;
-                       bool hasAutoReference = autoReference != null;
-                       Action<Task> adder = null;
-
-                       while (!predicateEvt.IsSet && watch.ElapsedMilliseconds < millisecondsTimeout && !self.IsCompleted) {
-                               // We try to execute the self task as it may be the simplest way to unlock
-                               // the situation
-                               if (self.Status == TaskStatus.WaitingToRun) {
-                                       self.Execute (hasAutoReference ? autoReference.adder : (Action<Task>)null);
-                                       if (predicateEvt.IsSet || watch.ElapsedMilliseconds > millisecondsTimeout)
-                                               return;
-                               }
-
-                               Task value;
-                               
-                               // If we are in fact a normal ThreadWorker, use our own deque
-                               if (hasAutoReference) {
-                                       var enumerable = autoReference.dDeque.GetEnumerable ();
-                                       if (adder == null)
-                                               adder = hasAutoReference ? autoReference.adder : (Action<Task>)null;
-
-                                       if (enumerable != null) {
-                                               foreach (var t in enumerable) {
-                                                       if (t == null)
-                                                               continue;
-
-                                                       if (checkTaskFitness (self, t))
-                                                               t.Execute (adder);
-
-                                                       if (predicateEvt.IsSet || watch.ElapsedMilliseconds > millisecondsTimeout)
-                                                               return;
-                                               }
-                                       }
-                               }
-
-                               int count = sharedWorkQueue.Count;
-
-                               // Dequeue only one item as we have restriction
-                               while (--count >= 0 && sharedWorkQueue.TryTake (out value) && value != null) {
-                                       evt.Set ();
-                                       if (checkTaskFitness (self, value) || aggressive)
-                                               value.Execute (null);
-                                       else {
-                                               if (autoReference == null)
-                                                       sharedWorkQueue.TryAdd (value);
-                                               else
-                                                       autoReference.dDeque.PushBottom (value);
-                                               evt.Set ();
-                                       }
-
-                                       if (predicateEvt.IsSet || watch.ElapsedMilliseconds > millisecondsTimeout)
-                                               return;
-                               }
-
-                               // First check to see if we comply to predicate
-                               if (predicateEvt.IsSet || watch.ElapsedMilliseconds > millisecondsTimeout)
-                                       return;
-                               
-                               // Try to complete other work by stealing since our desired tasks may be in other worker
-                               ThreadWorker other;
-                               for (int i = 0; i < others.Length; i++) {
-                                       if ((other = others [i]) == autoReference || other == null)
-                                               continue;
-
-                                       if (other.dDeque.PopTop (out value) == PopResult.Succeed && value != null) {
-                                               evt.Set ();
-                                               if (checkTaskFitness (self, value) || aggressive)
-                                                       value.Execute (null);
-                                               else {
-                                                       if (autoReference == null)
-                                                               sharedWorkQueue.TryAdd (value);
-                                                       else
-                                                               autoReference.dDeque.PushBottom (value);
-                                                       evt.Set ();
-                                               }
-                                       }
-
-                                       if (predicateEvt.IsSet || watch.ElapsedMilliseconds > millisecondsTimeout)
-                                               return;
-                               }
-
-                               /* Waiting is split in 4 phases
-                                *   - until stage 1 we simply yield the thread to let others add data
-                                *   - between stage 1 and stage2 we use ManualResetEventSlim light waiting mechanism
-                                *   - after stage2 we fall back to the heavier WaitHandle waiting mechanism
-                                *   - if really the situation isn't evolving after a couple of sleep, we disable
-                                *     task fitness check altogether
-                                */
-                               if (--tries > stage1)
-                                       Thread.Yield ();
-                               else if (tries >= stage2)
-                                       predicateEvt.Wait (ComputeTimeout (5, millisecondsTimeout, watch));
-                               else {
-                                       if (tries == stage2 - 1)
-                                               handles = new [] { predicateEvt.WaitHandle, evt };
-                                       System.Threading.WaitHandle.WaitAny (handles, ComputeTimeout (1000, millisecondsTimeout, watch));
-                                       if (tries == stage2 - 10)
-                                               aggressive = true;
-                               }
-                       }
-               }
-
-               public static ThreadWorker AutoReference {
-                       get {
-                               return autoReference;
-                       }
-                       set {
-                               autoReference = value;
-                       }
-               }
-
-               protected IConcurrentDeque<Task> Deque {
-                       get {
-                               return dDeque;
-                       }
-               }
-
-               protected ThreadWorker[] Others {
-                       get {
-                               return others;
-                       }
-               }
-
-               protected ManualResetEvent WaitHandle {
-                       get {
-                               return waitHandle;
-                       }
-               }
-
-               protected ThreadPriority Priority {
-                       get {
-                               return threadPriority;
-                       }
-               }
-
-               protected int WorkerPosition {
-                       get {
-                               return workerPosition;
-                       }
-               }
-
-               protected virtual void ChildWorkAdder (Task t)
-               {
-                       dDeque.PushBottom (t);
-                       waitHandle.Set ();
-               }
-
-               static int ComputeTimeout (int proposed, int timeout, Watch watch)
-               {
-                       return timeout == int.MaxValue ? proposed : System.Math.Min (proposed, System.Math.Max (0, (int)(timeout - watch.ElapsedMilliseconds)));
-               }
-               
-               public bool Finished {
-                       get {
-                               return started == 0;
-                       }
-               }
-
-               public int Id {
-                       get {
-                               return workerThread.ManagedThreadId;
-                       }
-               }
-               
-               public virtual bool Equals (ThreadWorker other)
-               {
-                       return (other == null) ? false : object.ReferenceEquals (this.dDeque, other.dDeque);    
-               }
-               
-               public override bool Equals (object obj)
-               {
-                       ThreadWorker temp = obj as ThreadWorker;
-                       return temp == null ? false : Equals (temp);
-               }
-               
-               public override int GetHashCode ()
-               {
-                       return workerThread.ManagedThreadId.GetHashCode ();
-               }
-       }
-}
-#endif
diff --git a/mcs/class/Mono.Parallel/Test/Mono.Threading.Tasks/MonoTaskExtensionsTests.cs b/mcs/class/Mono.Parallel/Test/Mono.Threading.Tasks/MonoTaskExtensionsTests.cs
deleted file mode 100644 (file)
index 62f939b..0000000
+++ /dev/null
@@ -1,67 +0,0 @@
-// 
-// MonoTaskExtensionsTests.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.Threading;
-using System.Threading.Tasks;
-
-using Mono.Threading.Tasks;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Threading.Tasks
-{
-       [TestFixtureAttribute]
-       public class MonoTaskExtensionsTests
-       {
-               [Test]
-               public void SimpleExecutionTest ()
-               {
-                       bool executed = false;
-                       Task t = new Task (() => executed = true);
-                       t.Execute (delegate {});
-
-                       Assert.IsTrue (executed);
-               }
-
-               [Test]
-               public void ExecutionWithChildCreationTest ()
-               {
-                       bool executed = false;
-                       bool childRetrieved = false;
-
-                       Task t = new Task (() => { Task.Factory.StartNew (() => Console.WriteLine ("execution")); executed = true; });
-                       t.Execute ((child) => childRetrieved = child != null);
-
-                       Assert.IsTrue (executed);
-                       Assert.IsTrue (childRetrieved);
-               }
-       }
-}
-
-#endif
diff --git a/mcs/class/Mono.Parallel/Test/Mono.Threading.Tasks/MonoTaskSchedulerTests.cs b/mcs/class/Mono.Parallel/Test/Mono.Threading.Tasks/MonoTaskSchedulerTests.cs
deleted file mode 100644 (file)
index 31d3b61..0000000
+++ /dev/null
@@ -1,108 +0,0 @@
-// 
-// MonoTaskSchedulerTests.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.Linq;
-using System.Threading;
-using System.Threading.Tasks;
-using System.Collections.Generic;
-
-using Mono.Threading.Tasks;
-
-using NUnit.Framework;
-
-namespace MonoTests.Mono.Threading.Tasks
-{
-       [TestFixtureAttribute]
-       public class MonoTaskSchedulerTests
-       {
-               class DummyScheduler : TaskScheduler, IMonoTaskScheduler
-               {
-                       public bool ParticipateMethod1 {
-                               get; set;
-                       }
-
-                       public bool ParticipateMethod2 {
-                               get; set;
-                       }
-
-                       protected override IEnumerable<Task> GetScheduledTasks ()
-                       {
-                               return Enumerable.Empty<Task> ();
-                       }
-
-                       protected override void QueueTask (Task task)
-                       {
-                               
-                       }
-
-                       protected override bool TryExecuteTaskInline (Task task, bool taskWasPreviouslyQueued)
-                       {
-                               throw new NotSupportedException ();
-                       }
-
-                       public void MonoParticipateUntil (Task task)
-                       {
-                               ParticipateMethod1 = true;
-                       }
-
-                       public bool MonoParticipateUntil (Task task, ManualResetEventSlim predicateEvt, int millisecondsTimeout)
-                       {
-                               ParticipateMethod2 = true;
-                               return true;
-                       }
-               }
-
-               [Test]
-               public void MethodRegisteringTest ()
-               {
-                       DummyScheduler sched = new DummyScheduler ();
-
-                       Task t = new Task (delegate { Thread.Sleep (100); });
-                       t.Start (sched);
-                       t.Wait ();
-
-                       Assert.IsTrue (sched.ParticipateMethod1);
-               }
-
-               [Test]
-               public void Method2RegisteringTest ()
-               {
-                       DummyScheduler sched = new DummyScheduler ();
-
-                       Task t = new Task (delegate { Thread.Sleep (100); });
-                       t.Start (sched);
-                       t.Wait (100);
-
-                       Assert.IsTrue (sched.ParticipateMethod2);
-               }
-
-       }
-}
-
-#endif