I wonder whether .NET CLR supports P/Invoke coarsening.
For example if开发者_运维技巧 we have three subsequent P/Invoke calls that deal with blittable types:
Native.DrawPolygon(1.0f, 1.0);
Native.DrawPolygon(2.0f, 1.0);
Native.DrawPolygon(3.0f, 1.0);
then we could perform managed-to-unmanaged context switch for the whole block just once, instead of doing it pointlessly three times.
No, the framework doesn't do this. You would have to build your API to minimise the managed-to-unmanaged switches.
精彩评论