Asynchronous Completion Token

 This article is extracted from POSA2 as my reading note.

See a familiar scene that all people experienced now and then: HTTP Cokkies. Web servers can use the Asynchronous Completion Token pattern if they expect responses from Web browsers. For example, a Web server may expect a user to transmit data they filled into a form that was downloaded from the server to the browser in response to a previous HTTP GET request. Due to the sessionless design of the HTTP protocol, and because users need not complete forms immediately, the Web server, acting in the role of a initiator, transmits a cookie(the ACT) to the Web browser along with the form. This cookie allows the server to associate the user's response with his or her original request for the form. Web browsers need not interpret the cookie, but simply return it unchanged to the Web server along with the completed form.

The Asynchronous Completion Token design pattern allows an application to demultiplex and process efficiently the responses of asynchronous operations it invokes on services. Four participants form the structure of the ACT pattern:

Service: A service provides some type of functionality that can be accessed asynchronously.

Initiator: A client initiator invokes operations on a service asynchronously. It also demultiplexes the response returned by these operations to a designated completion handler.

Completion handler: It is a function or object withit an application that is responsible for processing service responses.

ACT: An asynchronous completion token contains information that identifies a particular initiator's completion handler. The initiator passes the ACT to the service when it invokes an operation; the service returns the ACT to the initiator unchanged when the asynchronous operation completes. The initiator then uses this ACT to efficiently demultiplex to the completion handler that processes the response from the original asynchronous operation. Services can hold a collection of ACTs to handle multiple asynchronous operations invoked by initiators simultaneously.

 

 

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值