winrt-rust icon indicating copy to clipboard operation
winrt-rust copied to clipboard

Figure out the story around Send and Sync

Open Boddlnagg opened this issue 5 years ago • 0 comments

I haven't fully understood the Windows Runtime threading model yet. We should probably mark generated class as Send and/or Sync based on the ThreadingModel and MarshallingBehavior attributes. If I understand https://docs.microsoft.com/en-us/cpp/cppcx/threading-and-marshaling-c-cx?view=vs-2019 correctly, I think we could do the following:

I think we can mark a class as Sync if ThreadingModel is Both or MTA, based on this sentence:

If you author a class that has ThreadingModel=Both or ThreadingModel=MTA, make sure that the class is thread-safe.

I think we can mark a class as Send if MarshallingBehavior is Agile, based on this sentence:

In the vast majority of cases, instances of Windows Runtime classes, like standard C++ objects, can be accessed from any thread. Such classes are referred to as "agile"

It would be great if someone with more understanding could confirm these assumptions.

Related: #63, #18, #62, #60

Boddlnagg avatar May 18 '19 10:05 Boddlnagg