-
Notifications
You must be signed in to change notification settings - Fork 4.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[browser][MT] Marshal resolved/unresolved tasks separately (#99347)
Co-authored-by: Ilona Tomkowicz <32700855+ilonatommy@users.noreply.github.com>
- Loading branch information
1 parent
4e86b1c
commit b0f6444
Showing
5 changed files
with
112 additions
and
15 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
43 changes: 43 additions & 0 deletions
43
...Services.JavaScript/src/System/Runtime/InteropServices/JavaScript/JSAsyncTaskScheduler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
// Licensed to the .NET Foundation under one or more agreements. | ||
// The .NET Foundation licenses this file to you under the MIT license. | ||
|
||
using System.Collections.Generic; | ||
using System.Threading.Tasks; | ||
|
||
namespace System.Runtime.InteropServices.JavaScript | ||
{ | ||
// executes all tasks thru queue, never inline | ||
internal sealed class JSAsyncTaskScheduler : TaskScheduler | ||
{ | ||
private readonly JSSynchronizationContext m_synchronizationContext; | ||
|
||
internal JSAsyncTaskScheduler(JSSynchronizationContext synchronizationContext) | ||
{ | ||
m_synchronizationContext = synchronizationContext; | ||
} | ||
|
||
protected override void QueueTask(Task task) | ||
{ | ||
m_synchronizationContext.Post((_) => | ||
{ | ||
if (!TryExecuteTask(task)) | ||
{ | ||
Environment.FailFast("Unexpected failure in JSAsyncTaskScheduler" + Environment.CurrentManagedThreadId); | ||
} | ||
}, null); | ||
} | ||
|
||
// this is the main difference from the SynchronizationContextTaskScheduler | ||
protected override bool TryExecuteTaskInline(Task task, bool taskWasPreviouslyQueued) | ||
{ | ||
return false; | ||
} | ||
|
||
protected override IEnumerable<Task>? GetScheduledTasks() | ||
{ | ||
return null; | ||
} | ||
|
||
public override int MaximumConcurrencyLevel => 1; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters