-
I'm currently studying the codebase to evaluate how useful a port of the deadlock resolution to async frameworks on different runtimes would be and am a bit confused on the purpose of From what I can tell they contain a set of The publically visible call sites to code which consumes So whats the point of all this effort? It is optimized to not allocate in the common case of only having a single
Since If the factories are for different UI threads then I'm wondering if this code is even correct in the first place, why would it post to every underlying thread when targeting a specific JoinableTask? Doesn't this basically mean code can run on arbitrary threads which happen to be in the chain launching a So, any idea what the nesting factories code is there for? Any scenario it actually helps with? |
Beta Was this translation helpful? Give feedback.
Replies: 2 comments 2 replies
-
FYI @sharwell actually did port this to Java several years ago. At least, I think he did, but now I can't find anything on an Internet search to back that up. |
Beta Was this translation helpful? Give feedback.
-
This is not the reason. Multiple instances of
There is no such thing as nested You may create multiple You can see tests related to nested factories and this priorities scenario starting with this one (and others nearby in that file): vs-threading/test/Microsoft.VisualStudio.Threading.Tests/JoinableTaskTests.cs Lines 2686 to 2705 in f578222 |
Beta Was this translation helpful? Give feedback.
This is not the reason. Multiple instances of
JoinableTaskContext
never talk to each other. If you have two threads in the process that each have a single-threadedSynchronizationContext
applied, then conceivably twoJoinableTaskContext
instances may apply in that process, but they will not communicate and deadlocks may result if any code needs both threads to complete.There is no such thing as nested
JoinableTaskContext
. The contract is to have exactly one for a designated thread.You may