﻿<?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++博客-flyonok-随笔分类-ACE</title><link>http://www.cppblog.com/flyonok/category/13286.html</link><description /><language>zh-cn</language><lastBuildDate>Fri, 15 Oct 2010 08:22:16 GMT</lastBuildDate><pubDate>Fri, 15 Oct 2010 08:22:16 GMT</pubDate><ttl>60</ttl><item><title>通信程序需要考虑的几个问题</title><link>http://www.cppblog.com/flyonok/archive/2010/10/14/129853.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Thu, 14 Oct 2010 08:02:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/archive/2010/10/14/129853.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/129853.html</wfw:comment><comments>http://www.cppblog.com/flyonok/archive/2010/10/14/129853.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/129853.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/129853.html</trackback:ping><description><![CDATA[1、连接建立和服务的初始化<br>2、事件分发和事件多路<br>3、网络协议和进程间通信<br>4、主次存储管理和缓冲<br>5、动态和静态组件配置<br>6、并发和同步 <br>7、带宽管理、时延、部分失败检测和恢复、服务分区和负载均衡策略、线程调度策略、竞争条件、避免死锁<br>
<img src ="http://www.cppblog.com/flyonok/aggbug/129853.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2010-10-14 16:02 <a href="http://www.cppblog.com/flyonok/archive/2010/10/14/129853.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>通信程序的几个概念</title><link>http://www.cppblog.com/flyonok/archive/2010/10/05/128714.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Tue, 05 Oct 2010 13:20:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/archive/2010/10/05/128714.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/128714.html</wfw:comment><comments>http://www.cppblog.com/flyonok/archive/2010/10/05/128714.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/128714.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/128714.html</trackback:ping><description><![CDATA[1、通信程序的几个抽象层次：网络协议，事件分发机制，和并行结构（network protocols,event demultiplexing strategies, and concurrency architectures）；<br><br><span class=docEmphStrong>2、通信范围，讨论网络应用程序用来交互的规则，形式和抽象层次（<strong>Communication dimensions</strong></span> address the rules, form, and level of abstraction that networked applications use to interact）<br><br><span class=docEmphStrong>3、并行范围，讨论正确用进程和线程描述多服务实体的策略和机制，包括服务实体内部使用多线程（<strong>Concurrency dimensions</strong></span> address the policies and mechanisms governing the proper use of processes and threads to represent multiple service instances, as well as how each service instance may use multiple threads internally.）<br><br>4、<span class=docEmphStrong><strong>Service dimensions</strong></span> address key properties of a networked application service, such as the duration and structure of each service instance.<br>5、<span class=docEmphStrong><strong>Configuration dimensions</strong></span> address how networked services are identified and the time at which they are bound together to form complete applications. Configuration dimensions often affect more than one service, as well as the relationships between services.<br><img height=241 alt=graphics/00fig03.gif src="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/FILES/00fig03.gif" width=500 border=0>&nbsp;<br><img height=551 alt=graphics/00fig04.gif src="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/FILES/00fig04.gif" width=500 border=0><br>Host <span class=docEmphasis>infrastructure middleware</span> encapsulates OS concurrency and interprocess communication (IPC) mechanisms to create object-oriented network programming capabilities. These capabilities eliminate many tedious, error-prone, and nonportable activities associated with developing networked applications via native OS APIs, such as Sockets or POSIX threads (Pthreads). Widely used examples of host infrastructure middleware include Java Packages [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#agh00"><u><font color=#0000ff>AGH00</font></u></a>] and ACE<br>
<p class=docText><span class=docEmphasis>Distribution middleware</span> uses and extends host infrastructure middleware in order to automate common network programming tasks, such as connection and memory management, <span class=docEmphasis>marshaling</span> and <span class=docEmphasis>demarshaling</span>, end-point and request <span class=docEmphasis>demultiplexing</span>, synchronization, and multithreading. Developers who use distribution middleware can program distributed applications much like stand-alone applications, that is, by invoking operations on target objects without concern for their location, language, OS, or hardware [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#hv99">HV99</a>]. At the heart of distribution middleware are <span class=docEmphasis>Object Request Brokers</span> (ORBs), such as COM+ [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#box97">Box97</a>], Java RMI [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#sun98">Sun98</a>], and <em>CORBA</em> [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#obj01">Obj01</a>].</p>
<p class=docText><span class=docEmphasis>Common middleware services</span> augment distribution middleware by defining higher-level domain-independent services, such as event notification, logging, persistence, security, and recoverable transactions. Whereas distribution middleware focuses largely on managing end-system resources in support of an object-oriented distributed programming model, common middleware services focus on allocating, scheduling, and coordinating various resources throughout a distributed system. Without common middleware services, these end-to-end capabilities would have to be implemented <span class=docEmphasis>ad hoc</span> by each networked application.</p>
<table cellSpacing=0 cellPadding=0 width="100%" border=0>
    <tbody>
        <tr>
            <td vAlign=top>
            <h3 class=docSection1Title>0.3 Object-Oriented Middleware Solutions</h3>
            <p class=docText>Some of the most successful techniques and tools devised to address accidental and inherent complexities of networked applications have centered on object-oriented middleware, which helps manage the complexity and heterogeneity in networked applications. Object-oriented middleware provides reusable service/protocol component and framework software that functionally bridges the gap between</p>
            <span style="FONT-WEIGHT: bold">
            <ol class=docList type=1>
                <li><span style="FONT-WEIGHT: normal">
                <p class=docList>End-to-end application functional requirements and</p>
                </span>
                <li><span style="FONT-WEIGHT: normal">
                <p class=docList>The lower-level operating systems, networking <span class=docEmphasis>protocol</span> stacks, and hardware devices.</p>
                </span></li>
            </ol>
            </span>
            <p class=docText>Object-oriented middleware provides capabilities whose qualities are critical to help simplify and coordinate how networked applications are connected and how they interoperate.</p>
            <a name=ch00lev2sec1></a>
            <h4 class=docSection2Title>0.3.1 Object-Oriented Middleware Layers</h4>
            <p class=docText>Networking protocol stacks, such as TCP/IP [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#ste93">Ste93</a>], can be decomposed into multiple layers, such as the physical, data-link, network, transport, session, presentation, and application layers defined in the OSI reference model [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#bla91">Bla91</a>]. Likewise, object-oriented middleware can be decomposed into multiple layers [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#ss01">SS01</a>], as shown in <a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_ch00lev1sec3.html#ch00fig04">Figure 0.4</a>. A common hierarchy of object-oriented middleware includes the layers described below:</p>
            <center>
            <h5 class=docFigureTitle><a name=ch00fig04></a>Figure 0.4. Object-Oriented Middleware Layers in Context</h5>
            <p class=docText><img height=551 alt=graphics/00fig04.gif src="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/FILES/00fig04.gif" width=500 border=0></p>
            </center>
            <p class=docText>Host <span class=docEmphasis>infrastructure middleware</span> encapsulates OS concurrency and interprocess communication (IPC) mechanisms to create object-oriented network programming capabilities. These capabilities eliminate many tedious, error-prone, and nonportable activities associated with developing networked applications via native OS APIs, such as Sockets or POSIX threads (Pthreads). Widely used examples of host infrastructure middleware include Java Packages [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#agh00">AGH00</a>] and ACE.</p>
            <p class=docText><span class=docEmphasis>Distribution middleware</span> uses and extends host infrastructure middleware in order to automate common network programming tasks, such as connection and memory management, <span class=docEmphasis>marshaling</span> and <span class=docEmphasis>demarshaling</span>, end-point and request <span class=docEmphasis>demultiplexing</span>, synchronization, and multithreading. Developers who use distribution middleware can program distributed applications much like stand-alone applications, that is, by invoking operations on target objects without concern for their location, language, OS, or hardware [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#hv99">HV99</a>]. At the heart of distribution middleware are <span class=docEmphasis>Object Request Brokers</span> (ORBs), such as COM+ [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#box97">Box97</a>], Java RMI [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#sun98">Sun98</a>], and <em>CORBA</em> [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#obj01">Obj01</a>].</p>
            <p class=docText><span class=docEmphasis>Common middleware services</span> augment distribution middleware by defining higher-level domain-independent services, such as event notification, logging, persistence, security, and recoverable transactions. Whereas distribution middleware focuses largely on managing end-system resources in support of an object-oriented distributed programming model, common middleware services focus on allocating, scheduling, and coordinating various resources throughout a distributed system. Without common middleware services, these end-to-end capabilities would have to be implemented <span class=docEmphasis>ad hoc</span> by each networked application.</p>
            <p class=docText><span class=docEmphasis>Domain-specific middleware services</span> satisfy specific requirements of particular domains, such as telecommunications, e-commerce, health care, process automation, or avionics. Whereas the other object-oriented middleware layers provide broadly reusable "horizontal" mechanisms and services, domain-specific services target vertical markets. From a "commercial off-the-shelf" (COTS) perspective, domain-specific services are the least mature of the middleware layers today. This is due in part to the historical lack of middleware standards needed to provide a stable base upon which to create domain-specific services.</p>
            <p class=docText>Object-oriented middleware is an important tool for developing networked applications. It provides the following three broad areas of improvement for developing and evolving networked applications:</p>
            <span style="FONT-WEIGHT: bold">
            <ol class=docList type=1>
                <li><span style="FONT-WEIGHT: normal">
                <p class=docList><span class=docEmphStrong>Strategic focus,</span> which elevates application developer focus beyond a preoccupation with low-level OS concurrency and networking APIs. A solid grasp of the concepts and capabilities underlying these APIs is foundational to all networked application development. However, middleware helps abstract the details away into higher-level, more easily used artifacts. Without needing to worry as much about low-level details, developers can focus on more strategic, application-centric concerns.</p>
                </span>
                <li><span style="FONT-WEIGHT: normal">
                <p class=docList><span class=docEmphStrong>Effective reuse,</span> which amortizes software life-cycle effort by leveraging previous development expertise and reifying implementations of key patterns [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#ssrb00">SSRB00</a>, <a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#ghjv95">GHJV95</a>] into reusable middleware frameworks. In the future, most networked applications will be assembled by integrating and scripting domain-specific and common "pluggable" middleware service components, rather than being programmed entirely from scratch [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#joh97">Joh97</a>].</p>
                </span>
                <li><span style="FONT-WEIGHT: normal">
                <p class=docList><span class=docEmphStrong>Open standards,</span> which provide a portable and interoperable set of software artifacts. These artifacts help to direct the focus of developers toward higher-level software application architecture and design concerns, such as interoperable security, layered distributed resource management, and fault tolerance services. An increasingly important role is being played by open and/or standard COTS object-oriented middleware, such as CORBA, Java virtual machines, and ACE, which can be purchased or acquired via open-source means. COTS middleware is particularly important for organizations facing time-to-market pressures and limited software development resources.</p>
                </span></li>
            </ol>
            </span>
            <p class=docText>Although distribution middleware, common middleware services, and domain-specific middleware services are important topics, they are not treated further in this book for the reasons we explore in the next section. For further coverage of these topics, please see either <a class=docLink href="http://ace.ece.uci.edu/middleware.html" target=_blank>http://ace.ece.uci.edu/middleware.html</a> or <em>Advanced CORBA Programming with C++</em> [<a class=docLink href="mk:@MSITStore:E:\private\我的DBank\ace\CppNetwork%20Programming%20Volume%20I_MasteringComplexityWithACEandPatterns.chm::/0201604647_biblio.html#hv99">HV99</a>].</p>
            </td>
        </tr>
    </tbody>
</table>
<img src ="http://www.cppblog.com/flyonok/aggbug/128714.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2010-10-05 21:20 <a href="http://www.cppblog.com/flyonok/archive/2010/10/05/128714.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item><item><title>浅谈ACE_Reactor模式</title><link>http://www.cppblog.com/flyonok/archive/2010/03/17/109928.html</link><dc:creator>flyonok</dc:creator><author>flyonok</author><pubDate>Wed, 17 Mar 2010 13:50:00 GMT</pubDate><guid>http://www.cppblog.com/flyonok/archive/2010/03/17/109928.html</guid><wfw:comment>http://www.cppblog.com/flyonok/comments/109928.html</wfw:comment><comments>http://www.cppblog.com/flyonok/archive/2010/03/17/109928.html#Feedback</comments><slash:comments>0</slash:comments><wfw:commentRss>http://www.cppblog.com/flyonok/comments/commentRss/109928.html</wfw:commentRss><trackback:ping>http://www.cppblog.com/flyonok/services/trackbacks/109928.html</trackback:ping><description><![CDATA[ACE_Reactor模式减轻了程序员对底层网络IO事件监视的负担，一般情况下程序员只要继承ACE_Event_Handler类，重写相关的接口处理函数，然后向ACE_Reactor的对象注册相关事件即可，事件的定义在ACE_Event_Handler类中有相关定义，我用的最多是ACCEPT_MASK、READ_MASK、WRITE_MASK。<br>不同的事件调用不同的接口。相关的类图如下：<br><img style="width: 484px; height: 306px;" alt="reactor" id="reactor" src="http://www.cppblog.com/images/cppblog_com/flyonok/reactor.GIF"><br>一般情况下使用ACE_Reactor模式需要如下步骤：<br>1、继承ACE_Event_Handler,并重写感兴趣的接口函数，如handle_input,handle_output,handle_close等<br>2、生成ACE_Reactor实例，一般是一个线程一个，注意ACE_Reactor默认情况下不支持多线程,我经常通过instance函数获取唯一实例<br>3、生成第一步的事件处理对象实例，根据情况看是否使用new申请内存<br>4、通过ACE_Reactord的register_handle接口注册相关事件，相关事件的定义在ACE_Event_Handler类中有定义，我一般使用ACCEPT_MASK,READ_MASK,WRITE_MASK<br><br><br>  <img src ="http://www.cppblog.com/flyonok/aggbug/109928.html" width = "1" height = "1" /><br><br><div align=right><a style="text-decoration:none;" href="http://www.cppblog.com/flyonok/" target="_blank">flyonok</a> 2010-03-17 21:50 <a href="http://www.cppblog.com/flyonok/archive/2010/03/17/109928.html#Feedback" target="_blank" style="text-decoration:none;">发表评论</a></div>]]></description></item></channel></rss>