Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Set Rust callbacks to complete tasks asynchronously #279

Merged
merged 1 commit into from
Jun 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions src/Temporalio/Bridge/Client.cs
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@ public static async Task<Client> ConnectAsync(
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<Client>();
var completion = new TaskCompletionSource<Client>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.client_connect(
Expand Down Expand Up @@ -125,7 +126,8 @@ public async Task<T> CallAsync<T>(
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<ByteArray>();
var completion = new TaskCompletionSource<ByteArray>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.client_rpc_call(
Expand Down
9 changes: 6 additions & 3 deletions src/Temporalio/Bridge/EphemeralServer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,8 @@ public static async Task<EphemeralServer> StartTemporaliteAsync(
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<EphemeralServer>();
var completion = new TaskCompletionSource<EphemeralServer>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.ephemeral_server_start_dev_server(
Expand All @@ -76,7 +77,8 @@ public static async Task<EphemeralServer> StartTestServerAsync(
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<EphemeralServer>();
var completion = new TaskCompletionSource<EphemeralServer>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.ephemeral_server_start_test_server(
Expand All @@ -97,7 +99,8 @@ public async Task ShutdownAsync()
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<bool>();
var completion = new TaskCompletionSource<bool>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.ephemeral_server_shutdown(
Expand Down
18 changes: 12 additions & 6 deletions src/Temporalio/Bridge/Worker.cs
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,8 @@ public async Task ValidateAsync()
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<bool>();
var completion = new TaskCompletionSource<bool>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.worker_validate(
Expand Down Expand Up @@ -141,7 +142,8 @@ public void ReplaceClient(Client client)
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<ByteArray?>();
var completion = new TaskCompletionSource<ByteArray?>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.worker_poll_workflow_activation(
Expand Down Expand Up @@ -179,7 +181,8 @@ public void ReplaceClient(Client client)
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<ByteArray?>();
var completion = new TaskCompletionSource<ByteArray?>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.worker_poll_activity_task(
Expand Down Expand Up @@ -218,7 +221,8 @@ public async Task CompleteWorkflowActivationAsync(
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<bool>();
var completion = new TaskCompletionSource<bool>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.worker_complete_workflow_activation(
Expand Down Expand Up @@ -252,7 +256,8 @@ public async Task CompleteActivityTaskAsync(Api.ActivityTaskCompletion comp)
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<bool>();
var completion = new TaskCompletionSource<bool>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.worker_complete_activity_task(
Expand Down Expand Up @@ -338,7 +343,8 @@ public async Task FinalizeShutdownAsync()
{
using (var scope = new Scope())
{
var completion = new TaskCompletionSource<bool>();
var completion = new TaskCompletionSource<bool>(
TaskCreationOptions.RunContinuationsAsynchronously);
unsafe
{
Interop.Methods.worker_finalize_shutdown(
Expand Down