Skip to content

Use task instead of backgroundTask for Awaitable CE backing - #34

Merged
Eugene Tolmachev (et1975) merged 2 commits into
masterfrom
copilot/change-tasks-awaitable-backing
Jun 17, 2026
Merged

Use task instead of backgroundTask for Awaitable CE backing#34
Eugene Tolmachev (et1975) merged 2 commits into
masterfrom
copilot/change-tasks-awaitable-backing

Conversation

Copilot AI commented Jun 17, 2026

Copy link
Copy Markdown
Contributor

backgroundTask always offloads the CE's initial continuation to a thread-pool thread, even when that's unnecessary. Replacing it with task keeps execution on the calling thread, suspending only at genuine async boundaries.

Changes

  • AAD.fs/Awaitable.fs (#if TASKS branch): replace backgroundTask with task for the builder binding and both map/bind helpers
// before
let awaitable = backgroundTask
let inline map f (x:Task<_>) = backgroundTask { let! v = x in return f v }
let inline bind f (x:Task<_>) = backgroundTask { let! v = x in return! f v }

// after
let awaitable = task
let inline map f (x:Task<_>) = task { let! v = x in return f v }
let inline bind f (x:Task<_>) = task { let! v = x in return! f v }

Copilot AI changed the title [WIP] Change tasks' awaitable backing to use task Use task instead of backgroundTask for Awaitable CE backing Jun 17, 2026
@et1975
Eugene Tolmachev (et1975) marked this pull request as ready for review June 17, 2026 16:11
@et1975
Eugene Tolmachev (et1975) merged commit b52f53a into master Jun 17, 2026
3 checks passed
@et1975
Eugene Tolmachev (et1975) deleted the copilot/change-tasks-awaitable-backing branch June 17, 2026 16:29
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants