【跨套间访问】
COM对象接口只能在COM线程中调用,COM允许从一个套间中引出接口,并且引用到另一个套间中,使得对象的套间之外也能看到套间的接口。
COM使用一种称为列集(Marshal)的技术,允许接口指针可以被跨越套间边界传递出去。
列集一个接口指针,实际上只是简单地把接口指针变换成一个可被传输的字节流,散集这个字节流,就能还原出接口指针。当散集发生在同一套间的时候,散集出来的指针指向实际的对象;当散集发生在不同套间的时候,散集出来的指针实际指向的一是一个代理指针,通过这个代理指针,保证了COM对象的线程安全性。
以上三段小文字言简意赅地介绍了跨套间访问的散集/列集技术。如有未明,请查看《COM本质论》。