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 free threaded marshaling to all managed objects #836

Merged
merged 2 commits into from
May 5, 2021

Conversation

manodasanW
Copy link
Member

With the exception of the ones that implement IMarshal, we should implement the free threaded marshaler on the CCW of all managed objects. The free threaded marshaler is stored as a ThreadStatic to avoid retrieving it for each IMarshal call.

Contributes to #612

@manodasanW manodasanW requested review from Scottj1s and j0shuams May 5, 2021 06:13
}

// This object handles IMarshal calls for us for most scenarios.
[ThreadStatic]
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why ThreadStatic?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I wasn't sure whether the free threaded marshaler instance we get was thread safe itself or not and I didn't want to retrieve it each time for each call on a function. So I followed the pattern we use for the other buffer marshaler in CsWinRT (RoGetBufferMarshaler) where we use ThreadStatic.

@manodasanW manodasanW merged commit 396128c into master May 5, 2021
@manodasanW manodasanW deleted the manodasanw/freethreadedmarshaler branch May 5, 2021 22:04
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