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

Add memory barrier for bridge context #99

Merged

Conversation

youyuanwu
Copy link
Collaborator

mssf IFabricAsyncOperationContext implementation BridgeContext3 requires memory barrier to synchronize the operation complete status and the ctx content.
For example, a problematic way to use SF COM API:
Caller of SF COM API can call Begin operation, poll on ctx's status in a loop until complete using IsCompleted() api , and End operation without barriers. Without this change, this might cause the caller to forever be looping and polling the bool completed status. This is because the background thread set the status and result content in some memory location, but the memory location is not synchronized to the caller's thread.
There might be other ways including using callbacks that can result the same error behavior.

This PR fixes this to add proper memory barrier to ensure that completed status and the async operation result are visible by the callers' threads.

@youyuanwu youyuanwu marked this pull request as ready for review November 19, 2024 20:20
@youyuanwu youyuanwu merged commit 7b5ebe2 into Azure:main Nov 20, 2024
4 checks passed
@youyuanwu youyuanwu deleted the users/youyuanwu/memory-barrier-for-ctx branch November 20, 2024 23:01
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.

2 participants