Active Object

深入理解Active Object模式及其在并发架构中的应用 本文探讨了Active Object模式在并发编程中的优缺点,并提供了一个简化的实现示例。Active Object模式通过异步执行请求来提升系统吞吐量,并将同步挑战转嫁给实现者,但同时也存在性能开销和调试难度。文章还介绍了Monitor Object模式,它通过同步成员函数来确保对象在任意时刻只有一个成员函数运行,有助于解决数据竞争和死锁问题。 阅读详情
 

This article is extracted from POSA2 as a reading note.

The Active Object design pattern decouples method execution from method invocation to enhance concurrency and simplify synchronized access to objects that reside in their own threads of control.

An active object consists of six components:

Proxy: A proxy provides an interface that allows clients to invoke publicly accessible methods on an active object. The use of a proxy  permits applications to program using standard strongly typed language features, rather than passing loosely typed messages between threads. The proxy resides in the client's thread.

Method request: When a client invokes a method defined by the proxy  it triggers the construction of a method request object. A method request contains the context information, such as a method's parameters, necessary to execute a specific method invocation and return any result to the client. A method request class defines an interface for executing the methods of an active object. This interface also contains guard methods that can be used to determine when a method request can be executed. For every public method offered by a proxy that requires synchronized access in the active object, the method request class is subclassed to create a concrete method request class.

Activation list: A proxy inserts the concrete method request it creates into an activation list. This list maintains a bounded buffer of pending method requests created by the proxy and keeps track of which method requests can execute. The activation list decouples the client thread where the proxy resides from the thread  where the servant method is executed, so the two threads can run concurrently. The internal state of the activation list must therefore be serialized to protect it from concurrent access.

Scheduler: A scheduler runs in a different thread than its client proxies, namely in the active object's thread. It decides which method requst to execute next on an active object. This scheduling decision is based on various criteria, such as ordering - the order in which methods are called on the active object, or certain properties of an active object, such as its state. A scheduler can evaluate these properties using the method requests' guards, which determine when it is possible to execute the method request. A scheduler uses an activation list to manage method requests that are pending execution. Method requests are inserted in an activation list by a proxy when clients invoke one of its methods.

Servant: A servant defines the behavior and state that is modeled as an active object. The methods a servant implements correspond to  the interface of the proxy and method requests the proxy creates. It may also contain other predicate methods that method requests can use to implement their guards. A servant method is invoked when  its associated method request is executed by a scheduler. Thus, it  executes in its scheduler's thread.

Future: When a client invokes a method on a proxy it receives a future. This future allows the client to obtain the result of the method invocation after the servant finishes executing the method. Each future reserves space for the invoked method to store its result. When a client wants to obtain this result, it can rendezvous with the future, either blocking or polling until the result is computed and stored into the future.


 

【联邦学习】联邦平均(FedAvg)_附pytorch代码实现 其他代码包括1)数据集划分;2)训练;3)保存结果;4)绘图都可在 https://github.com/kt4ngw/fedavg-pytorch 找到。如果您对文章有建议及指定,也欢迎您留言评论,作者定当虚心修正。 阅读详情

相关推荐

AI智能体评估基准AgentBench:从原理到实战的完整指南

在人工智能领域,智能体(AI Agent)的评估是衡量其实际应用能力的关键环节。评估基准通过设计标准化的测试任务,系统性地检验智能体的推理、规划和工具使用等核心能力。其技术价值在于为模型迭代和产品选型提供了客观、可复现的量化依据,能有效推动技术从演示走向工程落地。典型的应用场景包括模型能力评测、智能体框架对比以及具体应用(如自动化运维、智能客服)的性能验证。本文聚焦于清华团队推出的AgentBench,它作为一个多维度的综合评估套件,涵盖了从操作系统、数据库操作到网页浏览、数字卡牌游戏等八个贴近真实世界的任

weixin_27207591的博客 599

踩坑记录:在实际中遇到的问题 python报错ValueError: generator already executing

踩坑记录:在实际中遇到的问题 python报错ValueError: generator already executing lists = ['30', '60', '90', '120', '500', '700'] for nums in lists: print(nums,'*********************') T1 = threading.Thread(target=activation_box,args=(nums,)) # sleep(

stu_py的博客 1048

从零实现机械臂抓取仿真:用MoveIt+Gazebo完成物体pick&place全流程

本文详细介绍了如何使用ROS的MoveIt框架与Gazebo仿真环境,从零构建机械臂抓取仿真系统。涵盖环境搭建、MoveIt配置、Gazebo集成、抓取动作实现等全流程,帮助开发者掌握机械臂控制的核心技术,实现高效的pick&place任务。

weixin_29250403的博客 477

Active Object 设计模式

一接受异步消息的主动对象 Active是“主动”的意思,ActiveObject是“主动对象”的意思,所谓主动对象就是指其拥有自己的独立线程,比如Thread实例就是一主动对象,不过ActiveObject设计模式不仅仅是拥有独立的线程,它还可以接受异步消息,并且能够返回处理的结果。 System.gc()方法就是一个“接受异步消息的主动对象”,调用gc方法的线程和gc自身的执行线程并不是同一线程。下图为接受异步消息的主动对象的工作原理图。 二标准ActiveOb...

实践求真知 994

AI Agent实战:WorkBuddy安装部署、任务执行与模型接入全教程

AI Agent是当前自动化办公与智能工作流的核心技术,它区别于传统问答式AI,能够理解目标、拆解任务并调用工具交付完整成果。其底层原理基于任务规划、工具调用与结果验证的循环机制,让机器从“提供建议”进化为“完成任务”。在工程实践中,合理配置模型服务(如接入DeepSeek)、设计标准化Skill(技能包)与自定义指令,可以显著提升Agent在报告生成、数据分析、竞品调研等场景中的稳定性与效率。WorkBuddy作为典型的任务式AI工作台,为运营、产品、开发等多角色提供了统一入口,覆盖安装部署、任务描述公式

weixin_26712075的博客 289

三模冗余设计

在数字电路设计中,Voter模块(表决器) 和 三模冗余(Triple Modular Redundancy, TMR) 是高可靠性系统的核心设计技术,主要用于容错和抗辐射(如航天、医疗设备等关键领域)。容错机制:若任一模块故障(如SEU,单粒子翻转),其他两个模块仍能保证正确输出。功耗与面积:TMR会显著增加资源占用(约3倍),需权衡可靠性和成本。航天电子:抗辐射芯片(如FPGA)中用于防止单粒子翻转(SEU)。故障检测:可扩展设计以检测并隔离故障模块(如通过BIST)。

qq_45776815的博客 2055

Active Object 设计模式实战

一Result package concurrent.activeobjects; public interface Result { Object getResultValue(); } 二RealResult package concurrent.activeobjects; public class RealResult implements Result { private final Object result; public RealResult(Ob..

实践求真知 699

【深度学习】最强算法之:残差网络(ResNet)

一篇掌握深度学习算法之:残差网络

商务合作 | 面试培训 | 职场规划 ==>主页扫码 7838

C++11的future和promise及active object并发模式

《C++并发编程实战》中提到了C++11中的future,网上查找一些资料大都只说了使用,并没有详细介绍future。本文简单介绍了我对future的理解

MeRcy_PM的博客 3810

亚马逊跨境电商选品数据分析:Python爬虫实战指南

本文将带领大家构建一套完整的亚马逊选品数据采集与分析系统,使用最新的Python技术栈,从零开始爬取亚马逊商品数据,并进行深度分析。

2201_76125261的博客 299

剪映自动化工具来了:AI帮你自动剪辑成片

🎬分享一个剪映自动化剪辑工具!AI 自动帮你完成从写文案、配音、加字幕、选音乐、上特效到最终导出的整套流程🎈

XiaoqiangClub的博客 858

设计模式:ACTIVE OBJECT模式

设计模式:ACTIVE OBJECT模式 ACTIVE OBJECT模式的定义与用法,工作中的用处,优劣势场景 参考: https://en.wikipedia.org/wiki/Active_object http://penghb.com/2018/02/07/designpatterns/activeObject/ ...

永立的专栏 1116

OpenCV计算机视觉实战(11)——边缘检测详解

在本节中,我们系统介绍了三大经典边缘检测算子,包括 Sobel 算子:一阶导数平衡了噪声抑制与边缘提取,结合方向信息可用于纹理分析与车道检测;Laplacian 算子:二阶导数对微小亮度突变尤为敏感,配合零交叉和细化技术,可精确捕捉任意方向的细节边缘;Canny 算法:集成多阶段处理与双阈值策略,通过多尺度融合与自适应阈值优化,达到抗噪与细节兼顾的卓越效果。

qq_30167691的博客 4377

ACTIVE OBJECT 模式 C# 版

《敏捷软件开发——原则、模式与实践》 Robert C.Martin 著,邓辉译,孟岩审,清华大学出版社,2003年9月第1版 第13章 COMMAND模式和ACTIVE OBJECT模式  没有人天生就具有命令他人的权利。     ——Denis Diderot(1713-1784,法国哲学家,百科全书编者)   在近几年记述过的所有设计模式中,我认为COMMAND模式是最简单、最优...

weixin_33895657的博客 196

假人有限元模型

假人模型,车辆碰撞假人有限元模型,适合做乘员安全的研究者利用

计算机控制技术及应用

《计算机控制技术及应用》通过总结作者的科研成果和吸收国内外的先进理论、方法和技术,以计算机控制系统的网络化、开放化、智能化和集成化发展趋势为主线索,主要介绍计算机控制系统的基本概念和计算机控制系统的典型形式,计算机控制系统的数学描述与基本分析方法,以及数字PID控制器、最少拍控制系统、达林算法、状态变量设计法等设计方法及其各种改进算法。重点突出计算机控制系统输入输出通道接口的设计方法和典型控制系统的设计案例与实现方法等。

多线程模式——Active Object(主动对象)模式

Active Object(主动对象)模式

buyoufa的博客 1952

最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版

Part-E1-SDIO-Specification-Ver4.00-Final-120220.pdf:最新的sdio 4.0 spec 协议标准 带书签 高清完整PDF版,包括SDIO 接口的外设,SDIO 接口官方协议等。

运用多种设计模式的综合案例_Go并发设计模式之 Active Object

点击上方蓝色“Go语言中文网”关注我们,领全套Go资料,每天学习Go语言本文作者:鸟窝smallnest原文链接:https://colobu.com/2019/07/02/concurrency-design-patterns-active-object/设计模式曾经很火,尤其是1995年的时候Erich Gamma, Richard Helm, Ralph Johnson 和 J...

weixin_39703926的博客 331

华为的C语言编程规范.pdf

华为技术有限公司内部技术规范。本规范制定了编写C语言程序的基本原则、规则和建议。从代码的清晰、简洁、可测试、安全、程序效率、可移植各个方面对C语言编程作出了具体指导。

稳固而知新 Command,Active Object,Composite

COMMAND Command 模式非常简单,只有一个具有唯一方法的接口组成。 public interface ICommand {        public void execute(); } 1 一般的Command模式        CommandMaster中绑定要执行的Command,只要Command监测到一个事件,它只要调用相应的Command执行即可,它无需指导要做什么事情

软件开发资料汇总 256

[置顶] Java多线程编程模式实战指南(一):Active Object模式(上)

本文由黄文海首次发布在infoq中文站上:http://www.infoq.com/cn/articles/Java-multithreaded-programming-mode-active-object-part1 。转载请注明作者: 黄文海 出处:http://viscent.iteye.com。   Active Object模式简介 Active Object模式是一种异步编程模式

vAgile的专栏 991

ACTIVE OBJECT 模式

ACTIVE OBJECT 模式 ——《敏捷软件开发 原则、模式与实践(c#版)》第21章 ACTIVE OBJECT 模式是建立在COMMAND模式的基础上。这是实现多线程控制的一项古老的技术。该模式有多种使用方式,为许多工业系统提供了一个简单的多任务核心。 想法很简单。考虑代码清单1-1和代码清单1-2。ActiveObjectEngine 对象...

aitinuo1702的博客 255

java active object模式_Java多线程编程模式实战指南:Active Object模式(下)

本文首次发布在infoq中文站上:外链网址已屏蔽2。转载请注明作者: 黄文海 出处:外链网址已屏蔽。Active Object模式的评价与实现考量Active Object模式通过将方法的调用与执行分离,实现了异步编程。有利于提高并发性,从而提高系统的吞吐率。Active Object模式还有个好处是它可以将任务(MethodRequest)的提交(调用异步方法)和任务的执行策略(Executio...

weixin_42356331的博客 190

Active Object模式

ActiveObject模式,很古老,但是在某些场合又很有威力。可以用一个单线程来控制多任务。通常配合Command模式使用。

zj510的专栏 4500

Symbian OS 开发初级手册 9 Active Object 基本概念

Symbian OS 开发初级手册 9 Active Object 基本概念 2004年 10月30日 上课讲了Symbian OS中多线程的使用, 这可我们说说Symbian OS中使用更频繁的一个框架:Active Object(这里简称AO)。 多线程在传统程序中使用非常的广泛, 但是在资源有限的小型设备上却不一定是上乘选择。 通过上课的例程我们看到每个线程都要分配一定的内存, 如果所有的异

mobilechannel的专栏 1817

Active Object模式深度解析:embedded-resources打造异步任务处理架构

在嵌入式系统开发中,Active Object模式(主动对象模式)是解决并发与异步任务处理问题的经典设计模式。本文以 GitHub 加速计划中的 embedded-resources 项目(Embedded Artistry 出品的模板、文档与源码资源库)为例,深度解析如何用 Active Object 模式为驱动与通信场景打造安全可靠的异步任务处理架构。即使你是刚入门的嵌入式新手,也能通过这篇文

gitblog_00402的博客 278

Active Object Pattern

Active Object Pattern

TimeTDIT的博客 1万+
上一篇: Double Checked Locking Optimization
下一篇: Monitor Object
hhf
hhf
博客等级 码龄17年 25粉丝 59原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

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

抵扣说明:

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

余额充值