On Thu Nov 9 13:11:18 2023 +0000, Alexandre Julliard wrote:
Is it really necessary to lock in AddRef?
As it is now, yes. Other threads can hold a reference to the `ITypeLib2` object, which would mean they could potentially call `AddRef` while the lock is held by another thread, which would mess up the reference count.
I guess we could move back to atomics on the reference count, which would remove the need to lock in `AddRef`. It'd feel a bit weird to enter the CS in `Release` and _then_ call `InterlockedDecrement`, just because we'd be using two layers of synchronization functions, but I can't come up with a scenario where that would necessarily break things.
Would you prefer using `InterlockedIncrement` in `AddRef` instead of using the CS lock?