Skip to content
This repository was archived by the owner on Jan 23, 2023. It is now read-only.

Commit 9615305

Browse files
marek-safarjkotas
authored andcommitted
Move Task factory type to shared partition (#22089)
1 parent efee815 commit 9615305

File tree

4 files changed

+8
-22
lines changed

4 files changed

+8
-22
lines changed

src/System.Private.CoreLib/System.Private.CoreLib.csproj

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -277,10 +277,8 @@
277277
<Compile Include="$(BclSourcesRoot)\System\Threading\Monitor.cs" />
278278
<Compile Include="$(BclSourcesRoot)\System\Threading\Overlapped.cs" />
279279
<Compile Include="$(BclSourcesRoot)\System\Threading\SynchronizationContext.cs" />
280-
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\FutureFactory.cs" />
281280
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\Task.cs" />
282281
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\TaskContinuation.cs" />
283-
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\TaskFactory.cs" />
284282
<Compile Include="$(BclSourcesRoot)\System\Threading\Tasks\TPLETWProvider.cs" />
285283
<Compile Include="$(BclSourcesRoot)\System\Threading\Thread.cs" />
286284
<Compile Include="$(BclSourcesRoot)\System\Threading\ThreadPool.cs" />

src/System.Private.CoreLib/shared/System.Private.CoreLib.Shared.projitems

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -777,11 +777,13 @@
777777
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\AsyncCausalityTracerConstants.cs" />
778778
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\ConcurrentExclusiveSchedulerPair.cs" />
779779
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\Future.cs" />
780+
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\FutureFactory.cs" />
780781
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\ProducerConsumerQueues.cs" />
781782
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskCanceledException.cs" />
782783
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskCompletionSource.cs" />
783784
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskExceptionHolder.cs" />
784785
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskExtensions.cs" />
786+
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskFactory.cs" />
785787
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskToApm.cs" />
786788
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskScheduler.cs" />
787789
<Compile Include="$(MSBuildThisFileDirectory)System\Threading\Tasks\TaskSchedulerException.cs" />

src/System.Private.CoreLib/src/System/Threading/Tasks/FutureFactory.cs renamed to src/System.Private.CoreLib/shared/System/Threading/Tasks/FutureFactory.cs

Lines changed: 6 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2,20 +2,7 @@
22
// The .NET Foundation licenses this file to you under the MIT license.
33
// See the LICENSE file in the project root for more information.
44

5-
// =+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+=+
6-
//
7-
//
8-
//
9-
// As with TaskFactory, TaskFactory<TResult> encodes common factory patterns into helper methods.
10-
//
11-
// =-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-=-
12-
13-
using System;
14-
using System.Security;
15-
using System.Runtime.CompilerServices;
16-
using System.Threading;
175
using System.Diagnostics;
18-
using System.Runtime.Versioning;
196

207
namespace System.Threading.Tasks
218
{
@@ -543,11 +530,7 @@ private static void FromAsyncCoreLogic(
543530
}
544531
else if (ex != null)
545532
{
546-
bool bWonSetException = promise.TrySetException(ex);
547-
if (bWonSetException && ex is ThreadAbortException)
548-
{
549-
promise.m_contingentProperties.m_exceptionsHolder.MarkAsHandled(false);
550-
}
533+
promise.TrySetException(ex);
551534
}
552535
else
553536
{
@@ -796,7 +779,6 @@ internal static Task<TResult> FromAsyncImpl(Func<AsyncCallback, object, IAsyncRe
796779

797780
try
798781
{
799-
//This is 4.5 behaviour
800782
//if we don't require synchronization, a faster set result path is taken
801783
var asyncResult = beginMethod(iar =>
802784
{
@@ -1250,7 +1232,7 @@ internal static Task<TResult> FromAsyncTrim<TInstance, TArgs>(
12501232
private sealed class FromAsyncTrimPromise<TInstance> : Task<TResult> where TInstance : class
12511233
{
12521234
/// <summary>A cached delegate used as the callback for the BeginXx method.</summary>
1253-
internal readonly static AsyncCallback s_completeFromAsyncResult = CompleteFromAsyncResult;
1235+
internal static readonly AsyncCallback s_completeFromAsyncResult = CompleteFromAsyncResult;
12541236

12551237
/// <summary>A reference to the object on which the begin/end methods are invoked.</summary>
12561238
private TInstance m_thisRef;
@@ -1305,6 +1287,10 @@ internal static void CompleteFromAsyncResult(IAsyncResult asyncResult)
13051287
/// <param name="thisRef">The target instance on which the end method should be called.</param>
13061288
/// <param name="endMethod">The end method to call to retrieve the result.</param>
13071289
/// <param name="asyncResult">The IAsyncResult for the async operation.</param>
1290+
/// <param name="requiresSynchronization">
1291+
/// Whether completing the task requires synchronization. This should be true
1292+
/// unless absolutely sure that the task has not yet been handed out to any consumers.
1293+
/// </param>
13081294
internal void Complete(
13091295
TInstance thisRef, Func<TInstance, IAsyncResult, TResult> endMethod, IAsyncResult asyncResult,
13101296
bool requiresSynchronization)
File renamed without changes.

0 commit comments

Comments
 (0)