Skip to content

Commit 5fb7fec

Browse files
committed
Scheduler: RequiresMarshalling samples current thread just once
1 parent 80746af commit 5fb7fec

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

src/CoroutineScheduler/Scheduler.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,11 @@ public Scheduler()
6363
private ContextCallback? Runner { get; set; }
6464

6565
private int? ResumingOnThread { get; set; }
66-
private bool RequiresMarshalling => ResumingOnThread is null || ResumingOnThread.Value != Thread.CurrentThread.ManagedThreadId;
66+
private bool RequiresMarshalling => ResumingOnThread switch
67+
{
68+
int resumingThread => resumingThread != Thread.CurrentThread.ManagedThreadId,
69+
_ => true,
70+
};
6771

6872
/// <summary>
6973
/// Resume any tasks that are at the point of invocation are currently awaiting `Yield()`, and <br />

0 commit comments

Comments
 (0)