Half-Sync/Half-Async

本文对POSA2中Half-Sync/Half-Async模式进行简要介绍,该模式在并发系统中通过分离异步和同步服务处理,简化编程过程同时保持性能,具体包括同步服务层、异步服务层、队列层和外部事件源的交互作用。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

This article makes a brief introduction of the Half-Sync/Half-Async pattern from POSA2 as my reading note.

The Half-Sync/Half-Async architectural pattern decouples asynchronous and synchronous service processing in concurrent systems, to simplify programming without unduly reducing performance. The pattern introduces two intercommunicating layers, one for asynchronous and one for synchronous service processing.

The structure of the Half-Sync/Half-Async pattern follows the Layers pattern and includes four participants:

Synchronous service layer: The synchronous service layer performs high level processing services. Services in the synchronous layer run in separate threads or processes that can block while performing operations.

Asynchronous service layer: The asynchronous service layer performs  lower level processing services, which typically emanate from one or more external event sources. Services in the asynchronous layer cannot block while performing operations without unduly degrading the performance of other services.

Queueing layer: The queueing layer provides the mechanism for communicating between services in the synchronous and asynchronous layers. For example, messages containing data and control information are produced by asynchronous services, then buffered at  the queueing layer for subsequent retrieval by synchronous services, and vice versa. The queueing layer is responsible for notifying services in one layer when messages are passed to them from the other layer. The queueing layer therefore enables the asynchronous and synchronous layers to interact in a 'producer/consumer' manner, similar to the structure defined by the  Pipes and Filters pattern.

External event sources: External event sources generate events that  are received and processed by the asynchronous service layer. Common sources of external events for operating systems include network interfaces, disk controllers, and end-user terminals.

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值