Branch: refs/heads/master
Home: https://github.com/mono/mono
Compare: https://github.com/mono/mono/compare/f33bd8ad7fe9...5d96c0de6379
Commit: e5bd8bc98bbc7f737c121d890749b431fbd6091f
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-09 08:43:41 GMT
URL: https://github.com/mono/mono/commit/e5bd8bc98bbc7f737c121d890749b431fbd6091f
Release continuation ancestor before running. Fixes #15036
Changed paths:
M mcs/class/corlib/System.Threading.Tasks/Task.cs
Modified: mcs/class/corlib/System.Threading.Tasks/Task.cs
===================================================================
@@ -49,8 +49,8 @@ public class Task : IDisposable, IAsyncResult
// parent is the outer task in which this task is created
readonly Task parent;
- // contAncestor is the Task on which this continuation was setup
- readonly Task contAncestor;
+ // A reference to a Task on which this continuation is attached to
+ Task contAncestor;
static int id = -1;
static readonly TaskFactory defaultFactory = new TaskFactory ();
@@ -500,7 +500,9 @@ internal void ChildCompleted (AggregateException childEx)
void InnerInvoke ()
{
if (IsContinuation) {
- invoker.Invoke (contAncestor, state, this);
+ var ancestor = contAncestor;
+ contAncestor = null;
+ invoker.Invoke (ancestor, state, this);
} else {
invoker.Invoke (this, state, this);
}
Commit: f410e545e2db0e0dc338673a6b10a5cfd2d3340f
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-09 09:26:34 GMT
URL: https://github.com/mono/mono/commit/f410e545e2db0e0dc338673a6b10a5cfd2d3340f
Allow to queue multicast delegates in thread-pool
Changed paths:
M mcs/class/corlib/System.Threading/ThreadPool.cs
M mcs/class/corlib/System/MulticastDelegate.cs
M mcs/class/corlib/Test/System.Threading/ThreadPoolTest.cs
Modified: mcs/class/corlib/System.Threading/ThreadPool.cs
===================================================================
@@ -87,9 +87,6 @@ public static bool QueueUserWorkItem (WaitCallback callBack, object state)
if (ar == null)
return false;
} else {
- if (!callBack.HasSingleTarget)
- throw new Exception ("The delegate must have only one target");
-
AsyncResult ares = new AsyncResult (callBack, state, true);
pool_queue (ares);
}
@@ -168,11 +165,11 @@ unsafe public static bool UnsafeQueueNativeOverlapped (NativeOverlapped *overlap
[SecurityPermission (SecurityAction.Demand, ControlEvidence=true, ControlPolicy=true)]
public static bool UnsafeQueueUserWorkItem (WaitCallback callBack, object state)
{
+ if (callBack == null)
+ throw new ArgumentNullException ("callBack");
+
// no stack propagation here (that's why it's unsafe and requires extra security permissions)
if (!callBack.IsTransparentProxy ()) {
- if (!callBack.HasSingleTarget)
- throw new Exception ("The delegate must have only one target");
-
AsyncResult ares = new AsyncResult (callBack, state, false);
pool_queue (ares);
return true;
Modified: mcs/class/corlib/System/MulticastDelegate.cs
===================================================================
@@ -72,9 +72,6 @@ protected sealed override object DynamicInvokeImpl (object[] args)
return base.DynamicInvokeImpl (args);
}
- internal bool HasSingleTarget {
- get { return prev == null; }
- }
// <remarks>
// Equals: two multicast delegates are equal if their base is equal
// and their invocations list is equal.
Modified: mcs/class/corlib/Test/System.Threading/ThreadPoolTest.cs
===================================================================
@@ -49,6 +49,35 @@ public void RegisterWaitForSingleObject_InvalidArguments ()
Assert.Fail ("#2");
} catch (ArgumentNullException) {
}
- }
+ }
+
+ [Test]
+ public void UnsafeQueueUserWorkItem_InvalidArguments ()
+ {
+ try {
+ ThreadPool.UnsafeQueueUserWorkItem (null, 1);
+ Assert.Fail ("#1");
+ } catch (ArgumentNullException) {
+ }
+ }
+
+ event WaitCallback e;
+
+ [Test]
+ public void UnsafeQueueUserWorkItem_MulticastDelegate ()
+ {
+ CountdownEvent ev = new CountdownEvent (2);
+
+ e += delegate {
+ ev.Signal ();
+ };
+
+ e += delegate {
+ ev.Signal ();
+ };
+
+ ThreadPool.UnsafeQueueUserWorkItem (e, null);
+ Assert.IsTrue (ev.Wait (3000));
+ }
}
}
\ No newline at end of file
Commit: e591a1d63c0700f5724a613cf3414c974df37e6d
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-09 09:39:14 GMT
URL: https://github.com/mono/mono/commit/e591a1d63c0700f5724a613cf3414c974df37e6d
Remove redundant initialization
Changed paths:
M mcs/class/corlib/System/MulticastDelegate.cs
Modified: mcs/class/corlib/System/MulticastDelegate.cs
===================================================================
@@ -43,19 +43,17 @@ namespace System
[StructLayout (LayoutKind.Sequential)]
public abstract class MulticastDelegate : Delegate
{
- private MulticastDelegate prev;
- private MulticastDelegate kpm_next;
+ MulticastDelegate prev;
+ MulticastDelegate kpm_next;
protected MulticastDelegate (object target, string method)
: base (target, method)
{
- prev = null;
}
protected MulticastDelegate (Type target, string method)
: base (target, method)
{
- prev = null;
}
public override void GetObjectData (SerializationInfo info, StreamingContext context)
Commit: 5d96c0de6379a3b30938f88e5f584b380f598f38
Author: Marek Safar <[email protected]> (marek-safar)
Date: 2013-10-09 10:51:16 GMT
URL: https://github.com/mono/mono/commit/5d96c0de6379a3b30938f88e5f584b380f598f38
Simplify work item registration for internal work items
Changed paths:
M mcs/class/corlib/System.Threading.Tasks/TpScheduler.cs
M mcs/class/corlib/System.Threading/ThreadPool.cs
M mcs/class/corlib/System.Threading/Timer.cs
Modified: mcs/class/corlib/System.Threading.Tasks/TpScheduler.cs
===================================================================
@@ -50,7 +50,7 @@ protected internal override void QueueTask (Task task)
return;
}
- ThreadPool.UnsafeQueueUserWorkItem (callback, task);
+ ThreadPool.QueueWorkItem (callback, task);
}
static void TaskExecuterCallback (object obj)
Modified: mcs/class/corlib/System.Threading/ThreadPool.cs
===================================================================
@@ -96,6 +96,12 @@ public static bool QueueUserWorkItem (WaitCallback callBack, object state)
[MethodImplAttribute(MethodImplOptions.InternalCall)]
static extern void pool_queue (AsyncResult ares);
+ // TODO: It should be interface interface only to avoid extra allocation
+ internal static void QueueWorkItem (WaitCallback callBack, object state)
+ {
+ pool_queue (new AsyncResult (callBack, state, false));
+ }
+
public static RegisteredWaitHandle RegisterWaitForSingleObject (WaitHandle waitObject,
WaitOrTimerCallback callBack,
object state,
Modified: mcs/class/corlib/System.Threading/Timer.cs
===================================================================
@@ -337,7 +337,7 @@ void SchedulerThread ()
list.RemoveAt (i);
count--;
i--;
- ThreadPool.UnsafeQueueUserWorkItem (TimerCB, timer);
+ ThreadPool.QueueWorkItem (TimerCB, timer);
long period = timer.period_ms;
long due_time = timer.due_time_ms;
bool no_more = (period == -1 || ((period == 0 || period == Timeout.Infinite) && due_time != Timeout.Infinite));
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches
lmpx.com only provides a reader for public news (NNTP) servers. It is not
affiliated with the servers or forums shown here and is not responsible for
the content of articles, which is written by their respective authors.