diff options
12 files changed, 31 insertions, 28 deletions
diff --git a/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/ExecutingMessageBoxBase.cs b/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/ExecutingMessageBoxBase.cs index b87e8601f5e..d6015665b28 100644 --- a/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/ExecutingMessageBoxBase.cs +++ b/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/ExecutingMessageBoxBase.cs @@ -136,7 +136,7 @@ namespace System.Threading.Tasks.Dataflow { protected override void OutgoingQueueComplete () { if (MessageQueue.IsCompleted - && Thread.VolatileRead (ref degreeOfParallelism) == 1) + && Volatile.Read (ref degreeOfParallelism) == 1) outgoingQueueComplete (); } @@ -145,7 +145,7 @@ namespace System.Threading.Tasks.Dataflow { /// </summary> protected override void VerifyCompleteness () { - if (Thread.VolatileRead (ref degreeOfParallelism) == 1) + if (Volatile.Read (ref degreeOfParallelism) == 1) base.VerifyCompleteness (); } @@ -160,4 +160,4 @@ namespace System.Threading.Tasks.Dataflow { || iteration < Options.MaxMessagesPerTask); } } -}
\ No newline at end of file +} diff --git a/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/MessageBox.cs b/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/MessageBox.cs index 239a610f727..867f803a9aa 100644 --- a/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/MessageBox.cs +++ b/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/MessageBox.cs @@ -80,7 +80,7 @@ namespace System.Threading.Tasks.Dataflow { return DataflowMessageStatus.DecliningPermanently; var full = options.BoundedCapacity != -1 - && Thread.VolatileRead (ref itemCount) >= options.BoundedCapacity; + && Volatile.Read (ref itemCount) >= options.BoundedCapacity; if (!greedy || full) { if (source == null) return DataflowMessageStatus.Declined; @@ -252,7 +252,7 @@ namespace System.Threading.Tasks.Dataflow { void RetrievePostponed () { // BoundedCapacity can't be -1 here, because in that case there would be no postponing - while (Thread.VolatileRead (ref itemCount) < options.BoundedCapacity + while (Volatile.Read (ref itemCount) < options.BoundedCapacity && !postponedMessages.IsEmpty && !MessageQueue.IsAddingCompleted) { var block = postponedMessages.First ().Key; DataflowMessageHeader header; @@ -286,7 +286,7 @@ namespace System.Threading.Tasks.Dataflow { postponedProcessing.Value = false; // because of race - if ((Thread.VolatileRead (ref itemCount) < options.BoundedCapacity + if ((Volatile.Read (ref itemCount) < options.BoundedCapacity || MessageQueue.IsAddingCompleted) && !postponedMessages.IsEmpty) EnsurePostponedProcessing (); @@ -329,4 +329,4 @@ namespace System.Threading.Tasks.Dataflow { CompHelper.Complete (); } } -}
\ No newline at end of file +} diff --git a/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/TargetCollection.cs b/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/TargetCollection.cs index 8b49b461d1c..cdd9bcb5839 100644 --- a/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/TargetCollection.cs +++ b/mcs/class/System.Threading.Tasks.Dataflow/System.Threading.Tasks.Dataflow/TargetCollection.cs @@ -167,7 +167,7 @@ namespace System.Threading.Tasks.Dataflow { { firstOffering = true; currentItem = item; - Thread.VolatileWrite (ref currentMessageHeaderId, ++lastMessageHeaderId); + Volatile.Write (ref currentMessageHeaderId, ++lastMessageHeaderId); ClearUnpostponed (); } @@ -184,14 +184,14 @@ namespace System.Threading.Tasks.Dataflow { public void ResetCurrentItem () { currentItem = default(T); - Thread.VolatileWrite (ref currentMessageHeaderId, 0); + Volatile.Write (ref currentMessageHeaderId, 0); } /// <summary> /// Is there an item to send right now? /// </summary> public bool HasCurrentItem { - get { return Thread.VolatileRead (ref currentMessageHeaderId) != 0; } + get { return Volatile.Read (ref currentMessageHeaderId) != 0; } } /// <summary> @@ -352,7 +352,7 @@ namespace System.Threading.Tasks.Dataflow { /// </summary> public bool VerifyHeader (DataflowMessageHeader header) { - return header.Id == Thread.VolatileRead (ref currentMessageHeaderId); + return header.Id == Volatile.Read (ref currentMessageHeaderId); } } @@ -520,4 +520,4 @@ namespace System.Threading.Tasks.Dataflow { return false; } } -}
\ No newline at end of file +} diff --git a/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/BoundedCapacityTest.cs b/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/BoundedCapacityTest.cs index 243bf6a74eb..bd8ccb579e0 100644 --- a/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/BoundedCapacityTest.cs +++ b/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/BoundedCapacityTest.cs @@ -133,7 +133,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { Assert.GreaterOrEqual (scheduler.ExecuteAll (), 1); - Assert.AreEqual (2, Thread.VolatileRead (ref n)); + Assert.AreEqual (2, Volatile.Read (ref n)); } [Test] @@ -156,7 +156,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { Assert.GreaterOrEqual (scheduler.ExecuteAll (), 1); - Assert.AreEqual (2, Thread.VolatileRead (ref n)); + Assert.AreEqual (2, Volatile.Read (ref n)); } int n; @@ -181,7 +181,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { Assert.IsFalse (transform.Post (102)); - Assert.AreEqual (10000, Thread.VolatileRead (ref n)); + Assert.AreEqual (10000, Volatile.Read (ref n)); } IEnumerable<int> ComputeResults () @@ -318,4 +318,4 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { throw new NotImplementedException (); } } -}
\ No newline at end of file +} diff --git a/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/ExecutionBlocksTest.cs b/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/ExecutionBlocksTest.cs index e4329e7982f..d523a8faa35 100644 --- a/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/ExecutionBlocksTest.cs +++ b/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/ExecutionBlocksTest.cs @@ -92,7 +92,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { var blocks = GetExecutionBlocksWithAction (() => { - if (Thread.VolatileRead (ref shouldRun) == 0) { + if (Volatile.Read (ref shouldRun) == 0) { ranAfterFault++; return; } @@ -122,7 +122,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { Thread.Sleep (100); - Assert.AreEqual (0, Thread.VolatileRead (ref ranAfterFault)); + Assert.AreEqual (0, Volatile.Read (ref ranAfterFault)); } } @@ -136,7 +136,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { var blocks = GetExecutionBlocksWithAsyncAction ( i => - tcs.Task.ContinueWith (t => Thread.VolatileWrite (ref result, i + t.Result)), + tcs.Task.ContinueWith (t => Volatile.Write (ref result, i + t.Result)), new ExecutionDataflowBlockOptions { TaskScheduler = scheduler }); foreach (var block in blocks) { @@ -160,7 +160,7 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { Assert.AreEqual (11, result); tcs = new TaskCompletionSource<int> (); - Thread.VolatileWrite (ref result, 0); + Volatile.Write (ref result, 0); } } @@ -196,4 +196,4 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { } } } -}
\ No newline at end of file +} diff --git a/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/OptionsTest.cs b/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/OptionsTest.cs index d59199e3fa0..27fce238a62 100644 --- a/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/OptionsTest.cs +++ b/mcs/class/System.Threading.Tasks.Dataflow/Test/System.Threading.Tasks.Dataflow/OptionsTest.cs @@ -215,10 +215,10 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { Assert.IsTrue (action.Post (1)); - Assert.AreEqual (0, Thread.VolatileRead (ref n)); + Assert.AreEqual (0, Volatile.Read (ref n)); Assert.AreEqual (1, scheduler.ExecuteAll ()); - Assert.AreEqual (1, Thread.VolatileRead (ref n)); + Assert.AreEqual (1, Volatile.Read (ref n)); } [Test] @@ -416,4 +416,4 @@ namespace MonoTests.System.Threading.Tasks.Dataflow { new[] { task1.Result, task2.Result }); } } -}
\ No newline at end of file +} diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs index 519f6ed2714..3ac6eed5f33 100644 --- a/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs +++ b/mcs/class/System.Web.Mvc2/System.Web.Mvc/Async/OperationCounter.cs @@ -20,7 +20,7 @@ namespace System.Web.Mvc.Async { public int Count {
get {
- return Thread.VolatileRead(ref _count);
+ return Volatile.Read(ref _count);
}
}
diff --git a/mcs/class/System.Web.Mvc2/System.Web.Mvc2.dll.sources b/mcs/class/System.Web.Mvc2/System.Web.Mvc2.dll.sources index 9ecb0aa8b11..bd35831db96 100644 --- a/mcs/class/System.Web.Mvc2/System.Web.Mvc2.dll.sources +++ b/mcs/class/System.Web.Mvc2/System.Web.Mvc2.dll.sources @@ -1,5 +1,6 @@ ../../build/common/Consts.cs ../../build/common/MonoTODOAttribute.cs +../corlib/System.Threading/Volatile.cs GlobalSuppressions.cs Properties/AssemblyInfo.cs diff --git a/mcs/class/System.Web.Mvc3/Mvc/Async/OperationCounter.cs b/mcs/class/System.Web.Mvc3/Mvc/Async/OperationCounter.cs index 5c8e5e5cfee..2c282ce28f5 100644 --- a/mcs/class/System.Web.Mvc3/Mvc/Async/OperationCounter.cs +++ b/mcs/class/System.Web.Mvc3/Mvc/Async/OperationCounter.cs @@ -8,7 +8,7 @@ public int Count { get { - return Thread.VolatileRead(ref _count); + return Volatile.Read(ref _count); } } diff --git a/mcs/class/System.Web.Mvc3/System.Web.Mvc3.dll.sources b/mcs/class/System.Web.Mvc3/System.Web.Mvc3.dll.sources index d65c2ff8989..bc649b13c04 100644 --- a/mcs/class/System.Web.Mvc3/System.Web.Mvc3.dll.sources +++ b/mcs/class/System.Web.Mvc3/System.Web.Mvc3.dll.sources @@ -1,3 +1,5 @@ +../corlib/System.Threading/Volatile.cs + ./GlobalSuppressions.cs ./GlobalAssemblyInfo.cs ./Mvc/AcceptVerbsAttribute.cs diff --git a/mcs/class/corlib/System.Threading.Tasks/Parallel.cs b/mcs/class/corlib/System.Threading.Tasks/Parallel.cs index 392458680e1..f509feacd02 100644 --- a/mcs/class/corlib/System.Threading.Tasks/Parallel.cs +++ b/mcs/class/corlib/System.Threading.Tasks/Parallel.cs @@ -203,7 +203,7 @@ namespace System.Threading.Tasks long old; StealValue64 val = new StealValue64 (); - old = Thread.VolatileRead (ref range.V64.Value); + old = Volatile.Read (ref range.V64.Value); val.Value = old; if (val.Actual >= stopIndex - val.Stolen - 2) diff --git a/mcs/class/corlib/System.Threading/SemaphoreSlim.cs b/mcs/class/corlib/System.Threading/SemaphoreSlim.cs index bf5f3da002f..db91e6d070d 100644 --- a/mcs/class/corlib/System.Threading/SemaphoreSlim.cs +++ b/mcs/class/corlib/System.Threading/SemaphoreSlim.cs @@ -166,7 +166,7 @@ namespace System.Threading SpinWait wait = new SpinWait (); - while (Thread.VolatileRead (ref currCount) <= 0) { + while (Volatile.Read (ref currCount) <= 0) { cancellationToken.ThrowIfCancellationRequested (); if (stopCondition ()) return false; |