﻿<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:trackback="http://madskills.com/public/xml/rss/module/trackback/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/"><channel><title>C++博客-Focus on ACE</title><link>http://www.cppblog.com/ace/</link><description>&lt;table style="border:1px solid #aa0033; font-size:small" align=center&gt;
  &lt;tr&gt;
    &lt;td rowspan=3&gt;
    
    &lt;/td&gt;
    &lt;td colspan=2 align=center&gt;&lt;b&gt;订阅 ace-china&lt;/b&gt;&lt;/td&gt;
  &lt;/tr&gt;
  &lt;form action="http://groups.google.com/group/ace-china/boxsubscribe"&gt;
  &lt;input type=hidden name="hl" value="zh-CN"&gt;
  &lt;tr&gt; 
    &lt;td&gt;电子邮件： &lt;input type=text name=email&gt;&lt;/td&gt;
    &lt;td&gt;
      &lt;table 
       style="background-color:#ffcc33;padding:2px;border:2px outset #ffcc33;"&gt;
      &lt;tr&gt;
        &lt;td&gt;
         &lt;input type=submit name="sub" value="订阅"&gt;
        &lt;/td&gt;
      &lt;/tr&gt;
      &lt;/table&gt;
    &lt;/td&gt;
  &lt;/tr&gt;
   &lt;/form&gt;
  &lt;tr&gt;&lt;td colspan=2 align=center&gt; 浏览存于  
	&lt;a href="http://groups.google.com/group/ace-china"&gt;groups.google.com&lt;/a&gt; 上的&lt;a href="http://groups.google.com/group/ace-china"&gt;所有帖子&lt;/a&gt; &lt;/td&gt;&lt;/tr&gt;
&lt;/table&gt;</description><language>zh-cn</language><lastBuildDate>Mon, 13 Apr 2026 12:52:15 GMT</lastBuildDate><pubDate>Mon, 13 Apr 2026 12:52:15 GMT</pubDate><ttl>60</ttl><item><title>欢迎访问我的新网站</title><link>http://www.cppblog.com/ace/archive/2012/07/02/181149.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Mon, 02 Jul 2012 09:03:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2012/07/02/181149.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/181149.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2012/07/02/181149.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/181149.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/181149.html</trackback:ping><description><![CDATA[<div>欢迎访问我的新网站<br />TAO工作室&nbsp;<a href="http://www.tao-studio.net">http://www.tao-studio.net<br /><br /><br /></a></div><img src ="http://www.cppblog.com/ace/aggbug/181149.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2012-07-02 17:03 <a href="http://www.cppblog.com/ace/archive/2012/07/02/181149.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>优先级反转</title><link>http://www.cppblog.com/ace/archive/2009/09/15/96240.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Tue, 15 Sep 2009 09:15:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2009/09/15/96240.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/96240.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2009/09/15/96240.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/96240.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/96240.html</trackback:ping><description><![CDATA[<p>Priority Inversion 优先级反转是嵌入式实时系统里面的一个经典的问题。简单描述一下这个问题：有三个优先级不同的task,A,B,C; A的优先级最高，B次之，C最低。其中A和C有共享的临界区。如果C已进入临界区，那么A在进入进入临界区之前，就会被阻塞。task B有可能打断C而进入运行状态，这样C什么时候从临界区退出，就是一个未知的时间。A只有C从临界区退出后才能被调度，A被阻塞的时间也是未知的。这样，低优先级的B先于高优先级的A被调度，优先级发生了逆转。 <br>这个问题在一般的操作系统里面不是一个严重的问题，最多A被多阻塞了一段时间。但是，在实时系统里面，如果一个任务在规定的时间里面没有被调度运行，系统就相当于失败了，可能引发系统崩溃。 <br>解决这个问题有两种手段： <br>1：Priority inheritance(优先级继承)，如果一个高优先级的task被阻塞，与它共享临界区的低优先级的task在进入临界区后，优先级就会继承高优先级task的优先级，保证它不会被其他优先级次高的任务打断。从临界区退出后，C的优先级恢复正常。 <br>2：A priority ceiling（最高优先级），给临界区分配最高优先级，如果一个task进入临界区，就把临界区的优先级赋给它，已保证它不会被打断。从临界区退出后，task的优先级恢复正常。</p> <p>实时操作系统的一个特点就是，一个实时任务，会在规定的时间内得到响应，并且在规定的时间内完成任务。所以，一切不可预知的动作都是有害的。</p> <p>有兴趣可以看看下面两个链接： <br><a href="http://en.wikipedia.org/wiki/Priority_inversion">http://en.wikipedia.org/wiki/Priority_inversion</a></p> <p>&nbsp;</p> <h3>Priority inversion</h3> <h5>From Wikipedia, the free encyclopedia</h5> <p>Jump to: <a href="http://en.wikipedia.org/#column-one">navigation</a>, <a href="http://en.wikipedia.org/#searchInput">search</a></p> <p>In <a href="http://en.wikipedia.org/wiki/Scheduling_(computing)">scheduling</a>, <b>priority inversion</b> is the scenario where a low priority <a href="http://en.wikipedia.org/wiki/Task">task</a> holds a shared <a href="http://en.wikipedia.org/wiki/Resource_(computer_science)">resource</a> that is required by a high priority task. This causes the execution of the high priority task to be blocked until the low priority task has released the resource, effectively "inverting" the relative priorities of the two tasks. If some other medium priority task, one that does not depend on the shared resource, attempts to run in the interim, it will take precedence over both the low priority task <i>and</i> the high priority task.</p> <p>In some cases, priority inversion can occur without causing immediate harm—the delayed execution of the high priority task goes unnoticed, and eventually the low priority task releases the shared resource. However, there are also many situations in which priority inversion can cause serious problems. If the high priority task is left <a href="http://en.wikipedia.org/wiki/Resource_starvation">starved</a> of the resources, it might lead to a system malfunction or the triggering of pre-defined corrective measures, such as a <a href="http://en.wikipedia.org/wiki/Watchdog_timer">watch dog timer</a> resetting the entire system. The trouble experienced by the Mars lander "<a href="http://en.wikipedia.org/wiki/Mars_Pathfinder">Mars Pathfinder</a>"<sup><a href="http://en.wikipedia.org/#cite_note-0">[1]</a></sup><sup><a href="http://en.wikipedia.org/#cite_note-1">[2]</a></sup> is a classic example of problems caused by priority inversion in <a href="http://en.wikipedia.org/wiki/Real-time_computing">realtime</a> systems.</p> <p>Priority inversion can also reduce the <a href="http://en.wikipedia.org/wiki/Perceived_performance">perceived performance</a> of the system. Low priority tasks usually have a low priority because it is not important for them to finish promptly (for example, they might be a <a href="http://en.wikipedia.org/wiki/Batch_job">batch job</a> or another non-interactive activity). Similarly, a high priority task has a high priority because it is more likely to be subject to strict time constraints—it may be providing data to an interactive user, or acting subject to realtime response guarantees. Because priority inversion results in the execution of the low priority task blocking the high priority task, it can lead to reduced system responsiveness, or even the violation of response time guarantees.</p> <p>A similar problem called <a href="http://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling#Deadline_interchange">deadline interchange</a> can occur within <a href="http://en.wikipedia.org/wiki/Earliest_deadline_first_scheduling">Earliest Deadline First Scheduling</a> (EDF).</p> <h4>Contents</h4>[<a href="http://en.wikipedia.org/">hide</a>]  <ul> <li><a href="http://en.wikipedia.org/#Solutions">1 Solutions</a>  <li><a href="http://en.wikipedia.org/#See_also">2 See also</a>  <li><a href="http://en.wikipedia.org/#Notes">3 Notes</a>  <li><a href="http://en.wikipedia.org/#References">4 References</a>  <li><a href="http://en.wikipedia.org/#External_links">5 External links</a> </li></ul> <p><a name="Solutions"></a></p> <h4>[<a href="http://en.wikipedia.org/w/index.php?title=Priority_inversion&amp;action=edit&amp;section=1">edit</a>] Solutions</h4> <p>The existence of this problem has been known since the 1970s, but there is no fool-proof method to predict the situation. There are however many existing solutions, of which the most common ones are:</p> <dl> <dt>Disabling all interrupts to protect critical sections  <dd>When disabled interrupts are used to prevent priority inversion, there are only two priorities: <i>preemptible</i>, and <i>interrupts disabled.</i> With no third priority, inversion is impossible. Since there's only one piece of lock data (the interrupt-enable bit), misordering locking is impossible, and so deadlocks cannot occur. Since the critical regions always run to completion, hangs do not occur. Note that this only works if all interrupts are disabled. If only a particular hardware device's interrupt is disabled, priority inversion is reintroduced by the hardware's prioritization of interrupts. A simple variation, "single shared-flag locking" is used on some systems with multiple CPUs. This scheme provides a single flag in shared memory that is used by all CPUs to lock all inter-processor critical sections with a <a href="http://en.wikipedia.org/wiki/Busy-wait">busy-wait</a>. Interprocessor communications are expensive and slow on most multiple CPU systems. Therefore, most such systems are designed to minimize shared resources. As a result, this scheme actually works well on many practical systems. These methods are widely used in simple <a href="http://en.wikipedia.org/wiki/Embedded_system">embedded systems</a>, where they are prized for their reliability, simplicity and low resource use. These schemes also require clever programming to keep the critical sections very brief, under 100 microseconds in practical systems. Many software engineers consider them impractical in general-purpose computers.  <dd>Arguably, these methods are similar to priority ceilings. </dd></dl> <dl> <dt>A <a href="http://en.wikipedia.org/wiki/Priority_ceiling">priority ceiling</a> <dd>With priority ceilings, the shared <a href="http://en.wikipedia.org/wiki/Mutual_exclusion">mutex</a> process (that runs the operating system code) has a characteristic (high) priority of its own, which is assigned to the task locking the mutex. This works well, provided the other high priority task(s) that try to access the mutex does not have a priority higher than the ceiling priority. </dd></dl> <dl> <dt><a href="http://en.wikipedia.org/wiki/Priority_inheritance">Priority inheritance</a> <dd>Under the policy of priority inheritance, whenever a high priority task has to wait for some resource shared with an executing low priority task, the low priority task is assigned the priority of the highest waiting priority task for the duration of its own use of the shared resource, thus keeping medium priority tasks from pre-empting the (originally) low priority task, and thereby effectively the waiting high priority task as well. </dd></dl> <p><a name="See_also"></a></p> <h4>[<a href="http://en.wikipedia.org/w/index.php?title=Priority_inversion&amp;action=edit&amp;section=2">edit</a>] See also</h4> <ul> <li><a href="http://en.wikipedia.org/wiki/Resource_starvation">Starvation</a>  <li><a href="http://en.wikipedia.org/w/index.php?title=Pre-emotive_multitasking&amp;action=edit&amp;redlink=1">Pre-emotive multitasking</a>  <li><a href="http://en.wikipedia.org/wiki/Non-blocking_synchronization">Non-blocking synchronization</a>  <li><a href="http://en.wikipedia.org/wiki/Read-copy-update">Read-copy-update</a>  <li><a href="http://en.wikipedia.org/wiki/Priority_inheritance">Priority inheritance</a>  <li><a href="http://en.wikipedia.org/wiki/Priority_ceiling">Priority ceiling</a>  <li><a href="http://en.wikipedia.org/wiki/Nice_(Unix)">Nice (Unix)</a> </li></ul> <p><a name="Notes"></a></p> <h4>[<a href="http://en.wikipedia.org/w/index.php?title=Priority_inversion&amp;action=edit&amp;section=3">edit</a>] Notes</h4> <ol> <li><b><a href="http://en.wikipedia.org/#cite_ref-0">^</a></b> <a href="http://research.microsoft.com/~mbj/Mars_Pathfinder/Authoritative_Account.html">What Really Happened on Mars</a> by Glenn Reeves of the JPL Pathfinder team  <li><b><a href="http://en.wikipedia.org/#cite_ref-1">^</a></b> <a href="http://research.microsoft.com/~mbj/Mars_Pathfinder/">Explanation of priority inversion problem experienced by Mars Pathfinder</a> </li></ol> <p><a name="References"></a></p> <h4>[<a href="http://en.wikipedia.org/w/index.php?title=Priority_inversion&amp;action=edit&amp;section=4">edit</a>] References</h4> <ul> <li><a href="http://portal.acm.org/citation.cfm?id=358824">"Experience with Processes and Monitors in Mesa"</a> by <a href="http://en.wikipedia.org/wiki/Butler_W._Lampson">Butler W. Lampson</a> and <a href="http://en.wikipedia.org/w/index.php?title=David_D._Redell&amp;action=edit&amp;redlink=1">David D. Redell</a>, <i><a href="http://en.wikipedia.org/wiki/Communications_of_the_ACM">CACM</a></i> 23(2):105-117 (Feb 1980) - One of the first (if not the) first papers to point out the priority inversion problem. Also suggested disabling interrupts and the priority ceiling protocol as solutions, noting that the former of these two cannot not tolerate page faults while in use. </li></ul> <p><a name="External_links"></a></p> <h4>[<a href="http://en.wikipedia.org/w/index.php?title=Priority_inversion&amp;action=edit&amp;section=5">edit</a>] External links</h4> <ul> <li><a href="http://wombat.doc.ic.ac.uk/foldoc/foldoc.cgi?priority+inversion">Description from FOLDOC</a>  <li><a href="http://citeseer.org/cs?q=priority+inversion">Citations from CiteSeer</a>  <li><a href="http://portal.acm.org/citation.cfm?coll=GUIDE&amp;dl=GUIDE&amp;id=626613">IEEE Priority Inheritance Paper by Sha, Rajkumar, Lehoczky</a> </li></ul> <p>Retrieved from "<a href="http://en.wikipedia.org/wiki/Priority_inversion">http://en.wikipedia.org/wiki/Priority_inversion</a>"</p><img src ="http://www.cppblog.com/ace/aggbug/96240.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2009-09-15 17:15 <a href="http://www.cppblog.com/ace/archive/2009/09/15/96240.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>如何在Windows,Visual C++下获取、配置和构建ACE及TAO?</title><link>http://www.cppblog.com/ace/archive/2008/07/22/56808.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Mon, 21 Jul 2008 17:00:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2008/07/22/56808.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/56808.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2008/07/22/56808.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/56808.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/56808.html</trackback:ping><description><![CDATA[<p>Q:如何在Windows,Visual C++下获取、配置和构建ACE及TAO?<br>A:本FAQ提供 在Windows下用VisualC++安装和构建ACE+TAO的基本说明。<br>&nbsp; <a title="" href="http://www.cs.wustl.edu/~schmidt/ACE.html " >ACE</a>+TAO也适用于其它主要的操作系统，例如：Linux, Solaris,<br>&nbsp; HP-UX, AIX和Tru64,还适用于一些实时，嵌入式操作系统，如<br>&nbsp; VxWorks,LynxOS, timeSys Linux和Windows CE。在Windows中，<br>&nbsp; <a title="" href="http://www.cs.wustl.edu/~schmidt/ACE.html " >ACE</a>+TAO也可以用Borland C++编译器构建。</p>
<p><br>&nbsp;.硬件要求：<br>&nbsp;&nbsp;&nbsp; - CPU： Intel X86 P3 500 MHz或更快<br>&nbsp;&nbsp;&nbsp; - 内存：512MB (更多内存可以提高编译速度)<br>&nbsp;&nbsp;&nbsp; - 硬盘空间： 256MB交互空间+ 250MB至数GB空闲空间（取瘊于您要有<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 多少需要构建)</p>
<p>&nbsp;.操作系统要求：<br>&nbsp;&nbsp;&nbsp; - Windows 2000, 2003,或XP&nbsp; (其实Vista下我试过也可以)<br>&nbsp; <br>&nbsp; <br>&nbsp;.C++编译器要求：<br>&nbsp; - Microsoft Visual C++ 6.0 SP5 (新版本的ACE+TAO已不支持VC6了)<br>&nbsp; - Microsoft Visual C++ 7.1 (VS2003)<br>&nbsp; - Microsoft Visual C++ 8.0 (VS2005)<br>&nbsp; - Microsoft Visaul C++ 9.0 (VS2008) </p>
<p>&nbsp;.其他软件要求：<br>&nbsp; - WinZIP或类似的解压缩工具<br>&nbsp; - ActiveState Perl v5.6.1或更新版本（推荐，不是必需）</p>
<p>&nbsp;获取和安装ACE+TAO<br>&nbsp; 1. 从下载OCI TAO 1.5a的最新补丁<br>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://download.ociweb.com/TAO-1.5a/ACE+TAO-1.5a_with_latest_patches.zip">http://download.ociweb.com/TAO-1.5a/ACE+TAO-1.5a_with_latest_patches.zip</a><br>&nbsp;&nbsp;&nbsp; 或从ACE+TAO的官方网站上下载最新Beta版<br>&nbsp;&nbsp;&nbsp;&nbsp; <a href="http://download.dre.vanderbilt.edu/">http://download.dre.vanderbilt.edu/</a><br>&nbsp; 2. 把上述压缩文件释入至没有空格的目录中（例如：C:\ACE_wrappers)<br>&nbsp; 3. 设置环境变量 ACE_ROOT,TAO_ROOT和PATH.<br>&nbsp;&nbsp;&nbsp;&nbsp; 例如：如果ACE+TAO安装至C:\ACE_wrappers,则上述环境变量如下：<br>&nbsp;&nbsp;&nbsp;&nbsp; * ACE_ROOT=C:\ACE_wrappers<br>&nbsp;&nbsp;&nbsp;&nbsp; * TAO_ROOT=%ACE_ROOT%\TAO<br>&nbsp;&nbsp;&nbsp;&nbsp; * PATH路径需要包含: %ACE_ROOT%\bin;%ACE_ROOT%\lib<br>&nbsp; 4. 在 %ACE_ROOT%\ace 目录中config.h文件，文件内容是：<br>&nbsp;&nbsp;&nbsp;&nbsp; #define ACE_DISABLE_WIN32_ERROR_WINDOWS<br>&nbsp;&nbsp;&nbsp;&nbsp; #define ACE_HAS_STANDARD_CPP_LIBRARY 1<br>&nbsp;&nbsp;&nbsp;&nbsp; #define ACE_DISABLE_WIN32_INCREASE_PRIORITY<br>&nbsp;&nbsp;&nbsp;&nbsp; #include "<a title="" href="http://www.cs.wustl.edu/~schmidt/ACE.html " >ACE</a>/config-win32.h"<br>&nbsp; 5. %TAO_ROOT%\TAOACE.sln<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 在ACETAO工作区(workspace)中的项目构建ACE和TAO库，TAO_IDL编译器、gperf,<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ORB服务库和可执行文件以及一些公共的实用工具(utilities)。他们不包含<br>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; 示例、测试和性能测试。库文件将安装至%ACE_ROOT%\lib，一些可执行文件将安装<br>&nbsp;&nbsp;&nbsp;&nbsp; 至%ACE_ROOT%\bin中，其他（ORB服务的可执行文件）将安装在他们自己的源代码所在<br>&nbsp;&nbsp;&nbsp;&nbsp; 目录中。<br>&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; 如果您不想全部建议TAOACE workspace的库和可执行文件，我们建议构建Naming_Service<br>&nbsp;&nbsp;&nbsp;&nbsp; 项目。在开发自己的应用程序里常会用到它。</p>
<p>&nbsp;&nbsp;&nbsp;&nbsp; 如果上述的workspace文件不存在，那么你需要用MakeProjectCreator (MPC)来生成它。<br>&nbsp;&nbsp;&nbsp;&nbsp; 命令行如下（需要Perl，上面已列出）：<br>&nbsp;&nbsp;&nbsp;&nbsp; cd %TAO_ROOT%<br>&nbsp;&nbsp;&nbsp;&nbsp; %ACE_ROOT%\bin\mwc.pl -type vc71 TAOACE.mwc -- 成生visual stuido 2003 workspace文件<br>&nbsp;&nbsp;&nbsp;&nbsp; %ACE_ROOT%\bin\mwc.pl -type vc8 TAOACE.mwc&nbsp; -- 成生visual stuido 2005 workspace文件<br>&nbsp;&nbsp;&nbsp;&nbsp; %ACE_ROOT%\bin\mwc.pl -type vc9 TAOACE.mwc&nbsp; -- 成生visual stuido 2008 workspace文件</p>
<p><br>&nbsp;&nbsp;&nbsp;&nbsp; <br>&nbsp;&nbsp;&nbsp;&nbsp; </p>
<p>&nbsp;</p><img src ="http://www.cppblog.com/ace/aggbug/56808.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2008-07-22 01:00 <a href="http://www.cppblog.com/ace/archive/2008/07/22/56808.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>欢迎访问www.ace-tao.org/bbs</title><link>http://www.cppblog.com/ace/archive/2007/12/05/37843.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Wed, 05 Dec 2007 04:59:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2007/12/05/37843.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/37843.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2007/12/05/37843.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/37843.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/37843.html</trackback:ping><description><![CDATA[欢迎访问http://<a href="http://www.ace-tao.org/bbs">www.ace-tao.org/bbs</a><br><br><br><img src ="http://www.cppblog.com/ace/aggbug/37843.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2007-12-05 12:59 <a href="http://www.cppblog.com/ace/archive/2007/12/05/37843.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>使用vs2005(vc8)编译log4cpp-0.3.5rc3</title><link>http://www.cppblog.com/ace/archive/2007/01/27/18050.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Sat, 27 Jan 2007 08:38:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2007/01/27/18050.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/18050.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2007/01/27/18050.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/18050.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/18050.html</trackback:ping><description><![CDATA[<div align="center">
				<h1>使用vs2005(vc8)编译log4cpp-0.3.5rc3</h1>
		</div>
		<div style="PADDING-RIGHT: 10px; PADDING-LEFT: 10px; PADDING-BOTTOM: 10px; PADDING-TOP: 10px; BACKGROUND-COLOR: #ffffff">
				<div style="PADDING-RIGHT: 0px; PADDING-LEFT: 0px; Z-INDEX: 100; FLOAT: right; PADDING-BOTTOM: 0px; MARGIN: 0px; PADDING-TOP: 0px">
				</div>
				<div>
						<p>问题：由于log4cpp-0.3.5rc3仅提供了vc6的工程文件，因此，使用vs2005打开后，需要进行转换。但是转换后，不能正确编译，提示Custom Build Step时出现了错误。</p>
						<p>分析：因为log4cpp在生成NTEventLogAppender.dll时，需要连接NTEventLogCategories.mc文件。所以，项目设置了自定义的生成步骤去生成NTEventLogAppender.dll。但从vc6的工程文件转换时，这些步骤却没有正确的转换过来。从而出现上述问题。</p>
						<p>解决方法：重新填写Custom Build Step项。</p>
						<p>其中，CommandLine填写以下内容：</p>
						<p>if not exist $(OutDir) md $(OutDir)<br />"mc.exe" -h $(OutDir) -r $(OutDir) $(SolutionDir)NTEventLogCategories.mc<br />"RC.exe" -r -fo $(OutDir)\$(InputName).res $(ProjectDir)\$(InputName).rc<br />"link.exe" /MACHINE:IX86 -dll -noentry -out:$(OutDir)\NTEventLogAppender.dll $(OutDir)\$(InputName).res</p>
						<p>Outputs填写：$(OutDir)\NTEventLogAppender.dll</p>
						<p>适用范围：log4cpp项目、log4cppDLL项目的Debug和Release配置。同时，该方法适用于vs2003(vc7.1)。</p>
				</div>
		</div><img src ="http://www.cppblog.com/ace/aggbug/18050.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2007-01-27 16:38 <a href="http://www.cppblog.com/ace/archive/2007/01/27/18050.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>TAO(The ACE ORB)简介</title><link>http://www.cppblog.com/ace/archive/2006/12/04/15959.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Mon, 04 Dec 2006 02:24:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2006/12/04/15959.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/15959.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2006/12/04/15959.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/15959.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/15959.html</trackback:ping><description><![CDATA[<p>TAO(The <a title="" href="http://www.cs.wustl.edu/~schmidt/ACE.html " >ACE</a> ORB)简介<br />TAO是一种开源的CORBA的实现。它是基于对象管理组织(OMG)标准CORBA参考模型,并通过自适应通讯环境(ACE)提供的软件概念和框架构建而成。这是一项中间件技术，这种技术使通用网络编程任务自动化，包括以下方面：<br />1.注册，定位和激活；<br />2.对象请求的多路分发；<br />3.分帧及错误处理；<br />4.参数编码和解码；和<br />5.操作的多路分解</p>
		<p><a title="" href="http://www.cs.wustl.edu/~schmidt/ACE.html " >ACE</a>/TAO的实现语言是C和C++。用ACE/TAO构建服务器和客户端的过程超出了本指南的范围，但有几个概念还是值得重提：<br />1. 接口(Interface)定义在OMG 标准的.idl文件中。用TAO_IDL实用程序,TAO可以自动通过.idl文件生成C++的静态存根(stubs)和框架(skeletions),二者分别用于服务器端和客户端.<br />2.程序员实现在生成的I.cpp静态存根中的接口，再使用惯用的CORBA技术来编写客户端和服务端的代码来进行实现。<br />3. <a title="" href="http://www.cs.wustl.edu/~schmidt/ACE.html " >ACE</a>/TAO提供了一个make实用程序，这个实用程序可以跨平台的管理项目的创建和编译。程序员编写的.mpc文件，定义了所创建的项目所需的源代码，Perl语言脚本创建makefile文件或Visual Sutdio的解决方案。在Linux上，可以生成GC++项目，命令是 mwc.pl -type gcace。在Windows上，产生Visual studio.net 2003解决方案的命令是:mwc.pl -type VC71</p><img src ="http://www.cppblog.com/ace/aggbug/15959.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2006-12-04 10:24 <a href="http://www.cppblog.com/ace/archive/2006/12/04/15959.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>ACE小技巧：在ACE_Acceptor框架中，自定义服务处理器的创建</title><link>http://www.cppblog.com/ace/archive/2006/08/30/11849.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Wed, 30 Aug 2006 06:11:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2006/08/30/11849.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/11849.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2006/08/30/11849.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/11849.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/11849.html</trackback:ping><description><![CDATA[<p>
				<span class="Title">ACE小技巧：在ACE_Acceptor框架中，自定义服务处理器的创建</span>
		</p>
		<p>
				<em><a title="Focus on ACE" href="http://www.cppblog.com/ace" >Stone Jiang</a></em>
		</p>
		<p>ACE_Acceptor框架使对新连接的侦听变得容易，也使创建和激活新连接的ACE_Svc_Handler的派生类变得容易。之前我们已经了解了ACE_Svc_Handle::open()挂勾函数和服务处理器</p>
		<p>初始化时它所扮演的角色。本文我们回退几步，来了解服务处理器是如何实例化的以及我们如何自定义它的行为。</p>
		<p>再看看ACE_Acceptor类，它是一个模板类，第一个模板参数ACE_Accetpor是代表与服务建立连接的处理器。当新的连接建立时，ACE_Acceptor调用make_svc_handler()挂勾函数来</p>
		<p>实际创建的新建服务处理器对象。ACE_Acceptor::make_svc_handler()的实现如下:<br /></p>
		<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
				<div>
						<span style="COLOR: #000000">template </span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000"> SVC_HANDLE,ACE_PEER_ACCEPTOR_1</span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000">
								<br />
						</span>
						<span style="COLOR: #0000ff">int</span>
						<span style="COLOR: #000000">
								<br />ACE_Acceptor</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">SVC_HANDLE, ACE_PEER_ACCEPTOR_2</span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000">::make_svc_handler(SVC_HANDLE</span>
						<span style="COLOR: #000000">*&amp;</span>
						<span style="COLOR: #000000"> sh)<br />{<br />  ACE_TRACE (</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">ACE_Acceptor&lt;SVC_HANDLER, ACE_PEER_ACCEPTOR_2&gt;::make_svc_handler</span>
						<span style="COLOR: #000000">"</span>
						<span style="COLOR: #000000">);  </span>
						<span style="COLOR: #0000ff">if</span>
						<span style="COLOR: #000000"> (sh </span>
						<span style="COLOR: #000000">==</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">)<br />    ACE_NEW_RETURN (sh,<br />                    SVC_HANDLER,<br />                    </span>
						<span style="COLOR: #000000">-</span>
						<span style="COLOR: #000000">1</span>
						<span style="COLOR: #000000">);  </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> Set the reactor of the newly created &lt;SVC_HANDLER&gt; to the same<br />  </span>
						<span style="COLOR: #008000">//</span>
						<span style="COLOR: #008000"> reactor that this &lt;ACE_Acceptor&gt; is using.</span>
						<span style="COLOR: #008000">
								<br />
						</span>
						<span style="COLOR: #000000">  sh</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">reactor (</span>
						<span style="COLOR: #0000ff">this</span>
						<span style="COLOR: #000000">-&gt;</span>
						<span style="COLOR: #000000">reactor ());<br />  </span>
						<span style="COLOR: #0000ff">return</span>
						<span style="COLOR: #000000"> </span>
						<span style="COLOR: #000000">0</span>
						<span style="COLOR: #000000">;<br /><br />}<br /></span>
				</div>
		</div>
		<p> </p>
		<p>默认的实现包括了两步基本操作：<br />1.  获得一个新的SVC_HANLDER对象， 这里是使用的new运算符分配的。<br />2.  设置新的服务处理器的reactor指针为ACE_Accetpor使用的reactor的。</p>
		<p>然而，如果应用程序需要通过其它方式获得SVC_HANDLER对象，而不是通过默认的构造函数那种动态分配，这又该怎么办呢？举例来说，我们可能需要：<br /> . 从一个预分配的池中获得SVC_HANDLER对象；<br /> . 为新创建的SVC_HANDLER传入一些额外的信息<br /> . 使用单体的SVC_HANDLER</p>
		<p>上面这些情形，我们都可以自定义make_svc_handler()挂勾函数来实现必要的行为。例如,假定我们新的处理器需要拥有一个处理所有对所有接收到的消息进行集中处理的中心处理</p>
		<p>器。这个中心处理器我们用类Processor表示。我们需要每个服务处理器都拥有一个指向中心处理器的指针，而不是使Processor成为一个全局访问的指针(使用全局变量的种种弊端</p>
		<p>本文不作详述)。我们的解决办法是: 从ACE_Accetor派生一个新类，这个新类拥有Processor的指针作成员，并且，在创建新和服务处理器(Service)的时候，把这个 Processor的</p>
		<p>指针作参数传进去。</p>
		<p>新的acceptor类可以这样定义：<br /></p>
		<div style="BORDER-RIGHT: windowtext 0.5pt solid; PADDING-RIGHT: 5.4pt; BORDER-TOP: windowtext 0.5pt solid; PADDING-LEFT: 5.4pt; BACKGROUND: #e6e6e6; PADDING-BOTTOM: 4px; BORDER-LEFT: windowtext 0.5pt solid; WIDTH: 95%; WORD-BREAK: break-all; PADDING-TOP: 4px; BORDER-BOTTOM: windowtext 0.5pt solid">
				<div>
						<img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />
						<span style="COLOR: #0000ff">class</span>
						<span style="COLOR: #000000"> My_Acceptor : </span>
						<span style="COLOR: #0000ff">public</span>
						<span style="COLOR: #000000"> ACE_Acceptor</span>
						<span style="COLOR: #000000">&lt;</span>
						<span style="COLOR: #000000">Service, ACE_SOCK_ACCEPTOR</span>
						<span style="COLOR: #000000">&gt;</span>
						<span style="COLOR: #000000">
								<br />
								<img id="_68_539_Open_Image" onclick="this.style.display='none'; document.getElementById('_68_539_Open_Text').style.display='none'; document.getElementById('_68_539_Closed_Image').style.display='inline'; document.getElementById('_68_539_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockStart.gif" align="top" />
								<img id="_68_539_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_68_539_Closed_Text').style.display='none'; document.getElementById('_68_539_Open_Image').style.display='inline'; document.getElementById('_68_539_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedBlock.gif" align="top" />
						</span>
						<span id="_68_539_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span>
						<span id="_68_539_Open_Text">
								<span style="COLOR: #000000">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" /></span>
								<span style="COLOR: #0000ff">public</span>
								<span style="COLOR: #000000">:<br /><img id="_140_142_Open_Image" onclick="this.style.display='none'; document.getElementById('_140_142_Open_Text').style.display='none'; document.getElementById('_140_142_Closed_Image').style.display='inline'; document.getElementById('_140_142_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="_140_142_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_140_142_Closed_Text').style.display='none'; document.getElementById('_140_142_Open_Image').style.display='inline'; document.getElementById('_140_142_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align="top" />  My_Acceptor (Processor </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">processor) : processor_ (processor) </span>
								<span id="_140_142_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span>
								<span id="_140_142_Open_Text">
										<span style="COLOR: #000000">{ }</span>
								</span>
								<span style="COLOR: #000000">;<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />  <br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />  </span>
								<span style="COLOR: #0000ff">int</span>
								<span style="COLOR: #000000"> make_svc_handler (Service </span>
								<span style="COLOR: #000000">*&amp;</span>
								<span style="COLOR: #000000">sh)<br /><img id="_190_502_Open_Image" onclick="this.style.display='none'; document.getElementById('_190_502_Open_Text').style.display='none'; document.getElementById('_190_502_Closed_Image').style.display='inline'; document.getElementById('_190_502_Closed_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockStart.gif" align="top" /><img id="_190_502_Closed_Image" style="DISPLAY: none" onclick="this.style.display='none'; document.getElementById('_190_502_Closed_Text').style.display='none'; document.getElementById('_190_502_Open_Image').style.display='inline'; document.getElementById('_190_502_Open_Text').style.display='inline';" alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ContractedSubBlock.gif" align="top" />    </span>
								<span id="_190_502_Closed_Text" style="BORDER-RIGHT: #808080 1px solid; BORDER-TOP: #808080 1px solid; DISPLAY: none; BORDER-LEFT: #808080 1px solid; BORDER-BOTTOM: #808080 1px solid; BACKGROUND-COLOR: #ffffff">...</span>
								<span id="_190_502_Open_Text">
										<span style="COLOR: #000000">{<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />      </span>
										<span style="COLOR: #0000ff">if</span>
										<span style="COLOR: #000000"> (sh </span>
										<span style="COLOR: #000000">==</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">)<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />        ACE_NEW_RETURN (sh,<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />                        Service (</span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">-&gt;</span>
										<span style="COLOR: #000000">processor_),<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />                        </span>
										<span style="COLOR: #000000">-</span>
										<span style="COLOR: #000000">1</span>
										<span style="COLOR: #000000">);      </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000"> Set the reactor of the newly created &lt;SVC_HANDLER&gt; to the same<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />      </span>
										<span style="COLOR: #008000">//</span>
										<span style="COLOR: #008000">  reactor that this &lt;ACE_Acceptor&gt; is using.</span>
										<span style="COLOR: #008000">
												<br />
												<img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />
										</span>
										<span style="COLOR: #000000">      sh</span>
										<span style="COLOR: #000000">-&gt;</span>
										<span style="COLOR: #000000">reactor (</span>
										<span style="COLOR: #0000ff">this</span>
										<span style="COLOR: #000000">-&gt;</span>
										<span style="COLOR: #000000">reactor ());<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />      </span>
										<span style="COLOR: #0000ff">return</span>
										<span style="COLOR: #000000"> </span>
										<span style="COLOR: #000000">0</span>
										<span style="COLOR: #000000">;<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedSubBlockEnd.gif" align="top" />    }</span>
								</span>
								<span style="COLOR: #000000">
										<br />
										<img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />
										<br />
										<img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />
								</span>
								<span style="COLOR: #0000ff">private</span>
								<span style="COLOR: #000000">:<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/InBlock.gif" align="top" />  Processor </span>
								<span style="COLOR: #000000">*</span>
								<span style="COLOR: #000000">processor_;<br /><img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/ExpandedBlockEnd.gif" align="top" />}</span>
						</span>
						<span style="COLOR: #000000">
								<br />
								<img alt="" src="http://images.csdn.net/syntaxhighlighting/OutliningIndicators/None.gif" align="top" />
						</span>
				</div>
		</div>
		<p> </p>
		<p>就这样，现在，当My_Acceptor接受新连接的时候，make_svc_handler()挂勾函数分配一个新的处理器(Service)，并把Processor*作为参数传进去。需要注意的事，尽管这里使用</p>
		<p>的是这一个构造函数Service(Processor*)。我们仍需求为Service类定义默认的构造函数，以满足模板类ACE_Acceptor的需要。</p>
		<p> </p><img src ="http://www.cppblog.com/ace/aggbug/11849.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2006-08-30 14:11 <a href="http://www.cppblog.com/ace/archive/2006/08/30/11849.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>小技巧: 当ACE_Svc_Handler关闭时使用的默认行为</title><link>http://www.cppblog.com/ace/archive/2006/08/28/11762.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Mon, 28 Aug 2006 01:36:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2006/08/28/11762.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/11762.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2006/08/28/11762.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/11762.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/11762.html</trackback:ping><description><![CDATA[<p>小技巧: 当ACE_Svc_Handler关闭时使用的默认行为</p>
		<p>
				<a title="Focus on ACE" href="/ace">Stone Jiang</a>
				<br />
				<br />上一篇我们看了ACE_Svc_Handler::open()挂勾函数提供默认行为的一些技巧。因为在大多数情况下，它完成了服务创建时所需的所有事情：为输入事件注册新处理器和返回。</p>
		<p>
				<br />在ACE_Svc_Handler中关闭操作的默认行为要比在open()中初始化的代码更为复杂。这是因为关闭时的挂勾函数包含了反应式(reactive)关闭和主动式(active-object)关闭两种情</p>
		<p>况，它们有相同的效果:删除所有在反应器注册的事件和确保删除ACE_Svc_handler的派生类的对象。</p>
		<p> </p>
		<p>反应式关闭(handle_close()): 当以下形况发生时被调用：<br /> 1) 事件回调函数(译注：handle_xxxx())返回-1时，或<br /> 2) 调用ACE_Reactor::remove_handler()，传入的标记不含 DONT_CALL时<br /> 反应器框架将调用handle_close()挂勾函数。 ACE_Svc_handler::handle_close()的默认行为是调用ACE_Svc_Handler::destroy()销毁事件处理器。</p>
		<p>
				<br />主动对象式关闭(close()): 当ACE_Svc_Handler 派生的对象通过activate()函数转变为主动对象，处理器的的svc()方法在它产生的线程中运行后进行回调。当svc()返回时，线程</p>
		<p>退出，但在它要退出时，仍在将要退出线程的上下文中，ACE_Task框架调用它的close()方法。ACE_Svc_Handler::close()方法调用handle_close()完成服务处理器的清理工作。</p>
		<p>因此，不管ACE_Svc_Handler对象是反应式还是主动式，结束时的清理工作都在相同的地方：ACE_Svc_Handler::destroy()。如果对象是动态分配且不是ACE_Stream框架中的组成部</p>
		<p>分，destroy()将删除此对象，如果对象不是动态分配的，析构它的责任是创建时对象所在的封闭范围。如果对象是ACE_Stream的模块的组成部分，流和/或控制流的代码负责管理</p>
		<p>对象的生命期。destroy()函数应遵守这样的规则来避免出现资源泄漏。</p>
		<p>
				<br />无论ACE_Svc_Handler对象是反应式销毁还是主动式销毁，都会引起相同的事情发生：~ACE_Svc_Handler() (处理器的析构函数)调用ACE_Svc_Handler::shutdown()函数完成服务处</p>
		<p>理器的清理工作。shutdown()执行的这些清理操作是：</p>
		<p> </p>
		<p>如果处理器与反应器是关联的：<br />   取消处理器关联的所有定时器。<br />   为处理器的流对象（如socket)删除所有已注册的事件。<br />如果处理器与再生器(recycler)是关系的，从再生器中清除处理器。<br />关闭流对象。<br />因此，我们看到的绝大多数情况服务处理器通过shutdown需要通过框架来清理工作，都是简单的允许缺省的挂勾函数得以被调用。如果你的应用程序需求更多的关闭/清理规则，推</p>
		<p>荐的地方是你的处理器的handle_close()挂勾方法。仅仅是确保把ACE_Svc_Handler::destroy()函数人作为你的handle_close()的最后一个动作，与框架清理行为的余下的行为合</p>
		<p>并。</p>
		<p>
				<br /> </p><img src ="http://www.cppblog.com/ace/aggbug/11762.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2006-08-28 09:36 <a href="http://www.cppblog.com/ace/archive/2006/08/28/11762.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>小技巧: ACE_Svc_Handler的初始化</title><link>http://www.cppblog.com/ace/archive/2006/08/27/11758.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Sun, 27 Aug 2006 15:48:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2006/08/27/11758.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/11758.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2006/08/27/11758.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/11758.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/11758.html</trackback:ping><description><![CDATA[<h1>小技巧: ACE_Svc_Handler的初始化</h1>
		<pre>
				<pre>
						<br />
						<br /><a title="Focus on ACE" href="http://www.cppblog.com/ace" >Stone Jiang</a><br /><pre>ACE_Svc_Handler经常用于网络服务类的基类，这是因为它很容易在主动对象(Active Ojbect)<br />模式和反应器(Reactor)框架中使用。APG第7.6节中讨论了怎么在接受器-连接器(Acceptor-conector)<br />框架中如何把ACE_Svc_Handler作为目标来使用，并且，在C++NPv2第7章中，深度探讨了<br />Acceotor-Connector的相关设计。</pre><pre>挂勾函数(Hook method)ACE_Svc_Handler::open()常是服务中新建连接时执行的初始化设置的地方。<br />举例来说，如果服务要在日志中记录新连接建立的相关信息，open()函数是则是记录这个信息的地方。<br />对于使用Reacotor 框架的服务检查网络数据到达，open()是执行reactor注册的地方。<br />事实上，这正是reactor注册的地方，这种动作在服务建立新连接时非常常见的，ACE_Svc_Handler::<br />open()的缺省操作也正是</pre><pre><pre>if (this-&gt;reactor () &amp;&amp; this-&gt;reactor ()-&gt;register_handler
          (this,
           ACE_Event_Handler::READ_MASK) == -1)
  ACE_ERROR_RETURN ((LM_ERROR,
                     ACE_LIB_TEXT ("%p\n"),
                     ACE_LIB_TEXT ("unable to register client handler")),
                    -1);
return 0;
</pre></pre><pre>所以，如果在与服务建立新连接并为“读事件”注册时，你甚至不需要在你的类中<br />实现open(void*)函数，ACE已经为你做了这一步!另外，请记住，如果reactor注册失败，<br />默认的open()函数会返回-1，它会引起Acceptor-Connector框架关闭新建的连接和删除这个<br />事件处理器(handler)。<br /><a title="Focus on ACE" href="/ace">Stone Jiang</a><br /><a href="/ace/">http://www.cppblog.com/ace/</a><br /><br /></pre></pre>
		</pre><img src ="http://www.cppblog.com/ace/aggbug/11758.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2006-08-27 23:48 <a href="http://www.cppblog.com/ace/archive/2006/08/27/11758.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>有人知道CSDN邮件列表的退订方式吗?</title><link>http://www.cppblog.com/ace/archive/2006/08/08/10975.html</link><dc:creator>Stone Jiang</dc:creator><author>Stone Jiang</author><pubDate>Tue, 08 Aug 2006 04:27:00 GMT</pubDate><guid>http://www.cppblog.com/ace/archive/2006/08/08/10975.html</guid><wfw:comment>http://www.cppblog.com/ace/comments/10975.html</wfw:comment><comments>http://www.cppblog.com/ace/archive/2006/08/08/10975.html#Feedback</comments><slash:comments>1</slash:comments><wfw:commentRss>http://www.cppblog.com/ace/comments/commentRss/10975.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/ace/services/trackbacks/10975.html</trackback:ping><description><![CDATA[<p>几乎每天收到一封到几封不想看的垃圾邮件,邮件中却没有退订功能.<br />并且,根本就没有订过这类邮件.<br />不知道有没有人也有同样的烦恼?<br /></p><img src ="http://www.cppblog.com/ace/aggbug/10975.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/ace/" target="_blank">Stone Jiang</a> 2006-08-08 12:27 <a href="http://www.cppblog.com/ace/archive/2006/08/08/10975.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>