码迷,mamicode.com
首页 > 其他好文 > 详细

COM是如何实现STA的

时间:2014-12-23 22:27:10      阅读:454      评论:0      收藏:0      [点我收藏+]

标签:

Rather than using thread synchronization objects (mutexes, semaphores, and so forth) to control access to an object by several threads, the marshaling process for STAs translates the call into a WM_USER message and posts the result to a hidden top-level window associated with the apartment when it was created. Calls from several different threads are converted and sent to wait in the apartment‘s message queue until they are retrieved, dispatched, and executed on the apartment‘s thread. This process controls access to an apartment‘s objects by forcing incoming calls to pass through a sort of turnstile, thereby rendering the object‘s interface implementations thread-safe. An additional benefit of using the message queue is that inter-apartment COM calls are synchronized with window messages, which provides a means for objects that interact with users to synchronize incoming COM calls with the operation of the user interface (UI).

也就是说基于消息队列,串行化调用请求实现单线程模式。

COM是如何实现STA的

标签:

原文地址:http://www.cnblogs.com/wusong/p/4181233.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!