temporalio / sdk-dotnet

Temporal .NET SDK
MIT License
375 stars 30 forks source link

Set Rust callbacks to complete tasks asynchronously #279

Closed cretz closed 2 months ago

cretz commented 2 months ago

What was changed

We use TaskCompletionSource for callbacks from Rust threads, but resolving a task completion source in a non-.NET thread and await/continue-with in the same thread it was started in can have deadlock issues in certain situations. Setting TaskCreationOptions.RunContinuationsAsynchronously forces the task to schedule its continuation instead of running inline in same blocking thread. We now set this on every completion source callback used by Rust.

The test suite cannot easily replicate this because it is top level, but this was tested against the replication in #248.

Checklist

  1. Closes #248