Remove SchedulerProxy
authorJérémie Laval <jeremie.laval@gmail.com>
Thu, 13 Oct 2011 20:14:29 +0000 (22:14 +0200)
committerJérémie Laval <jeremie.laval@gmail.com>
Thu, 13 Oct 2011 20:14:29 +0000 (22:14 +0200)
mcs/class/corlib/System.Threading.Tasks/SchedulerProxy.cs [deleted file]
mcs/class/corlib/System.Threading.Tasks/TaskScheduler.cs
mcs/class/corlib/corlib.dll.sources

diff --git a/mcs/class/corlib/System.Threading.Tasks/SchedulerProxy.cs b/mcs/class/corlib/System.Threading.Tasks/SchedulerProxy.cs
deleted file mode 100644 (file)
index 3220fe4..0000000
+++ /dev/null
@@ -1,118 +0,0 @@
-// 
-// SchedulerProxy.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 || MOBILE
-using System;
-using System.Threading;
-using System.Reflection;
-
-namespace System.Threading.Tasks
-{
-       internal class SchedulerProxy
-       {
-               TaskScheduler scheduler;
-
-               Action<Task> participateUntil1;
-               Func<Task, ManualResetEventSlim, int, bool> participateUntil2;
-
-               public SchedulerProxy (TaskScheduler scheduler)
-               {
-                       this.scheduler = scheduler;
-                       FindMonoSpecificImpl ();
-               }
-
-               void FindMonoSpecificImpl ()
-               {
-                       // participateUntil1
-                       FetchMethod<Action<Task>> ("MonoParticipateUntil",
-                                                  new[] { typeof(Task) },
-                                                  ref participateUntil1);
-                       // participateUntil2
-                       FetchMethod<Func<Task, ManualResetEventSlim, int, bool>> ("MonoParticipateUntil",
-                                                                                 new[] { typeof(Task), typeof(ManualResetEventSlim), typeof(int) },
-                                                                                 ref participateUntil2);
-               }
-
-               void FetchMethod<TDelegate> (string name, Type[] types, ref TDelegate field) where TDelegate : class
-               {
-                       var method = scheduler.GetType ().GetMethod (name,
-                                                                    BindingFlags.Instance | BindingFlags.Public,
-                                                                    null,
-                                                                    types,
-                                                                    null);
-                       if (method == null)
-                               return;
-                       field = Delegate.CreateDelegate (typeof(TDelegate), scheduler, method) as TDelegate;
-                       Console.WriteLine ("Created delegate for " + name);
-               }
-
-               public void ParticipateUntil (Task task)
-               {
-                       if (participateUntil1 != null) {
-                               participateUntil1 (task);
-                               return;
-                       }
-
-                       if (task.Status == TaskStatus.WaitingToRun)
-                               task.Execute (null);
-
-                       if (task.IsCompleted)
-                               return;
-
-                       ManualResetEventSlim evt = new ManualResetEventSlim (false);
-                       task.ContinueWith (_ => evt.Set (), TaskContinuationOptions.ExecuteSynchronously);
-
-                       ParticipateUntil (evt, -1);
-               }
-               
-               public bool ParticipateUntil (Task task, ManualResetEventSlim evt, int millisecondsTimeout)
-               {
-                       if (task.IsCompleted)
-                               return false;
-
-                       if (participateUntil2 != null)
-                               return participateUntil2 (task, evt, millisecondsTimeout);
-
-                       bool fromPredicate = true;
-                       task.ContinueWith (_ => { fromPredicate = false; evt.Set (); }, TaskContinuationOptions.ExecuteSynchronously);
-
-                       ParticipateUntil (evt, millisecondsTimeout);
-
-                       return fromPredicate;
-               }
-
-               void ParticipateUntil (ManualResetEventSlim evt, int millisecondsTimeout)
-               {
-                       evt.Wait (millisecondsTimeout);
-               }
-
-               public void PulseAll ()
-               {
-                       
-               }
-       }
-}
-#endif
index fc43fbf0436c1b016a516505d49c5c223f663b85..d69a62bfd5745429fa763b5fbd18774077ab3203 100644 (file)
@@ -36,7 +36,6 @@ namespace System.Threading.Tasks
        public abstract class TaskScheduler
        {
                static TaskScheduler defaultScheduler = new TpScheduler ();
-               SchedulerProxy proxy;
                
                [ThreadStatic]
                static TaskScheduler currentScheduler;
@@ -49,7 +48,6 @@ namespace System.Threading.Tasks
                protected TaskScheduler ()
                {
                        this.id = Interlocked.Increment (ref lastId);
-                       this.proxy = new SchedulerProxy (this);
                }
 
                ~TaskScheduler ()
@@ -92,21 +90,6 @@ namespace System.Threading.Tasks
                        }
                }
 
-               internal virtual void ParticipateUntil (Task task)
-               {
-                       proxy.ParticipateUntil (task);
-               }
-
-               internal virtual bool ParticipateUntil (Task task, ManualResetEventSlim predicateEvt, int millisecondsTimeout)
-               {
-                       return proxy.ParticipateUntil (task, predicateEvt, millisecondsTimeout);
-               }
-
-               internal virtual void PulseAll ()
-               {
-                       proxy.PulseAll ();
-               }
-
                protected abstract IEnumerable<Task> GetScheduledTasks ();
                protected internal abstract void QueueTask (Task task);
                protected internal virtual bool TryDequeue (Task task)
index 0f61d95ef1ed57e97d23351cec2e43640ffa7a5b..986d792bcadf806dc04286e0240b482d407fb02f 100644 (file)
@@ -1546,7 +1546,6 @@ System.Threading.Tasks/TaskFactory.cs
 System.Threading.Tasks/TaskFactory_T.cs
 System.Threading.Tasks/TaskStatus.cs
 System.Threading.Tasks/TaskCreationOptions.cs
-System.Threading.Tasks/SchedulerProxy.cs
 System.Threading.Tasks/CyclicDeque.cs
 System.Threading.Tasks/IConcurrentDeque.cs
 System.Threading.Tasks/PopResult.cs