Skip to content

[AI Task] Use RunContinuationsAsynchronously for RemoteResource async TCS - #7785

Open
JoonghyunCho wants to merge 1 commit into
mainfrom
ai-task/issue-7699
Open

[AI Task] Use RunContinuationsAsynchronously for RemoteResource async TCS#7785
JoonghyunCho wants to merge 1 commit into
mainfrom
ai-task/issue-7699

Conversation

@JoonghyunCho

Copy link
Copy Markdown
Member

Summary

RemoteResource.GetAsync / PutAsync / PostAsync / DeleteAsync created their TaskCompletionSource<RemoteResponse> with the default constructor, so the awaiting continuation resumed synchronously on the native iotcon callback thread that calls TrySetResult / TrySetException. This is a classic deadlock / re-entrancy hazard: user code after the await could re-enter native iotcon or block while running inline on the native callback thread. All four TCS constructions now pass TaskCreationOptions.RunContinuationsAsynchronously, matching the same fix already applied for WiFi (#7620), NFC (#7676), Bluetooth (#7666), and Remoting (#7639).

Changes

  • src/Tizen.Network.IoTConnectivity/Tizen.Network.IoTConnectivity/RemoteResource.cs: added TaskCreationOptions.RunContinuationsAsynchronously to the 4 method-local TaskCompletionSource<RemoteResponse> constructions in GetAsync, PutAsync, PostAsync, and DeleteAsync.

Mode

Refactoring

Verification

  • Build: passed (0 warnings, 0 errors)
  • Tests: N/A (no unit tests for this module; change is a TCS creation flag only)
  • Benchmark: skipped (sdb error: no device attached)

Fixes #7699

… TCS (Fixes #7699)

Construct the TaskCompletionSource in GetAsync/PutAsync/PostAsync/DeleteAsync
with TaskCreationOptions.RunContinuationsAsynchronously so awaiting
continuations resume on the ThreadPool instead of running inline on the
native iotcon callback thread, removing a deadlock/re-entrancy hazard.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
@gemini-code-assist

Copy link
Copy Markdown

Caution

The consumer version of Gemini Code Assist on GitHub has been sunset. All code review activity has officially ceased.

@github-actions github-actions Bot added the API15 label Aug 2, 2026
@JoonghyunCho

Copy link
Copy Markdown
Member Author

⚠️ Benchmark skipped: No sdb device is attached (sdb devices returned an empty list), so the comparative benchmark could not be deployed or run. Manual benchmark verification is required. Note: this change only adds TaskCreationOptions.RunContinuationsAsynchronously to method-local TCS constructions, which adds zero allocations; the expected effect is moving await continuations off the native iotcon callback thread onto the ThreadPool.

@JoonghyunCho

Copy link
Copy Markdown
Member Author

🤖 [AI Review]

Reviewed — no findings.

Scope checked:

  • Confirmed all 4 TaskCompletionSource<RemoteResponse> constructions in the file (GetAsync, PutAsync, PostAsync, DeleteAsync) now pass TaskCreationOptions.RunContinuationsAsynchronously — no site missed; the only other TaskCompletionSource references are the _taskCompletionMap field and callback-local variables.
  • Verified the native result callback handlers TryRemove the TCS from _taskCompletionMap and fully marshal the RemoteResponse before calling TrySetResult/TrySetException, so no code path depends on the continuation running inline on the iotcon callback thread.
  • No public API signature change; the behavior change only moves post-await user code off the native callback thread, which is the stated intent and matches the equivalent WiFi TCS fix.
  • The methods are [Obsolete] (deprecated since API level 13) but still shipped, so the deadlock/re-entrancy hardening remains applicable to existing consumers.

No 🔴 critical issues, no 🟡 suggestions to flag.


Automated review — final merge decision rests with human reviewers.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

1 participant