Skip to Content
Dapr学习手册
book

Dapr学习手册

by Haishi Bai, Yaron Schneider
November 2021
Beginner to intermediate
239 pages
4h 15m
Chinese
China Electric Power Press Ltd.
Content preview from Dapr学习手册
156
5
Actor
在当今计算机科学已知的许多编程模型中,
actor
模型是一个突出的模型。
如你将在本章中了解到的那样,
Dapr
为该编程模型提供了一种高效,轻便且
灵活的实现,并能够支持任何的一种现代编程语言。
5.1 Actor
模式
在计算机科学中,
actor
模型被描述为用于并行计算的数学模型。可以将
actor
视为这些计算的原语:它在收到一条消息后,可以基于该消息做出本地决策。
actor
封装了自己的状态,并通过使用唯一
ID
进行分区的方式实现了可伸缩
性。一旦收到消息后,
actor
就可以对该消息进行响应,连接到外部系统或者
是再创建出其他类型的
actor
。一
actor
可以是有状态的也可以是无状态的:
有状态时,它会修改自己的内部状态。这带来了面向对象编程的体验,对象
的状态被封装在其中,并通过强类型方法进行修改。
actor
总是以回合制的并
发模型被调用,并允许对
actor
的任何给定实例的单线程访问。
例如,图
5-1
展示了对类型为
Cat
的同一个
actor
实例的两个并发调用(调用
Eat
方法)将以串行方式执行。
Actor
157
方法调用 1 方法调用 2
方法执行
状态改变
方法退出
方法执行
状态改变
方法退出
5
-
1
:基于回合的 actor ...
Become an O’Reilly member and get unlimited access to this title plus top books and audiobooks from O’Reilly and nearly 200 top publishers, thousands of courses curated by job role, 150+ live events each month,
and much more.

Read now

Unlock full access

More than 5,000 organizations count on O’Reilly

AirBnbBlueOriginElectronic ArtsHomeDepotNasdaqRakutenTata Consultancy Services

QuotationMarkO’Reilly covers everything we've got, with content to help us build a world-class technology community, upgrade the capabilities and competencies of our teams, and improve overall team performance as well as their engagement.
Julian F.
Head of Cybersecurity
QuotationMarkI wanted to learn C and C++, but it didn't click for me until I picked up an O'Reilly book. When I went on the O’Reilly platform, I was astonished to find all the books there, plus live events and sandboxes so you could play around with the technology.
Addison B.
Field Engineer
QuotationMarkI’ve been on the O’Reilly platform for more than eight years. I use a couple of learning platforms, but I'm on O'Reilly more than anybody else. When you're there, you start learning. I'm never disappointed.
Amir M.
Data Platform Tech Lead
QuotationMarkI'm always learning. So when I got on to O'Reilly, I was like a kid in a candy store. There are playlists. There are answers. There's on-demand training. It's worth its weight in gold, in terms of what it allows me to do.
Mark W.
Embedded Software Engineer

You might also like

流畅的Python(第2版)

流畅的Python(第2版)

Luciano Ramalho
数据科学原理

数据科学原理

Posts & Telecom Press, Sinan Ozdemir
Python预测分析实战

Python预测分析实战

Posts & Telecom Press, Alvaro Fuentes
机器学习开发者指南

机器学习开发者指南

Posts & Telecom Press, Rodolfo Bonnin

Publisher Resources

ISBN: 9787519859367