知识库--Using Akka Refs and Transactions(124)
来源:互联网 发布:淘宝卖家钱多久到账 编辑:程序博客网 时间:2024/05/29 16:32
//Akka – Ref
Unlike Clojure, where refs were defined at the language level, Akka can’trely on any existing language support. Instead, Akka provides, as part of the akka.stm package, a managed transactional reference Ref and specialized classes for primitive types such as IntRef, LongRef, and so on. The Ref (and the specialized references) represents the managed mutable identity to an immutable value of type T. Types like Integer, Long, Double, String, and other immutable types fit the bill well to serve as value objects. If we use one of our own classes, we must make sure it’s immutable, that is, that it contains only final fields.
//Ref的使用get() swap()
We can create a managed transactional reference, which is an instance of Ref, by providing an initial value or by omitting the value, defaulting to null. To obtain the current value from the reference, use the get() method. To change the mutable identity to point to a new value, use the swap() method. These calls are performed within the transaction we provide or in their own individual transactions if none is provided.
//并发处理 HB原则
When multiple threads try to change the same managed reference, Akka ensures that changes by one are written to memory and the others are retried. The transactional facility takes care of crossing the memory barriers. That is, Akka, through Multiverse, guarantees that the changes to a managed ref committed by a transaction happen before, and are visible to, any reads of the same ref later in other transactions.
- 知识库--Using Akka Refs and Transactions(124)
- 知识库--Collections and Transactions Using TransactionalMap(136)
- 知识库--Sending and Receiving Messages By Akka Using Java(139)
- 知识库--Creating Transaction in Java Using Akka(124)
- 知识库--Creating Nested Transactions By Akka 内存嵌套事务(129)
- 知识库--Akka 事务配置-using jvm(134)
- 知识库--Creating Actors By Akka Using Java(139)
- 知识库--Akka Commit and Rollback Events in Java(136)
- Large-scale Incremental Processing Using Distributed Transactions and Notifications
- Update Data Using Transactions
- 经典论文翻译导读之《Large-scale Incremental Processing Using Distributed Transactions and Notifications》
- 经典论文翻译导读之《Large-scale Incremental Processing Using Distributed Transactions and Notifications》 转载
- Refs and the DOM
- Transactions and Exceptions
- Distributed Transactions and Timeouts
- Distributed Transactions and Timeouts
- Sessions and transactions
- Transactions and Consistency
- IDEA 专门发布了一个golang的IDE叫Goland
- 第七章:存储过程
- 关于指针的15个经典面试题
- 第六章:事务,视图和索引
- 第五章:项目:我的租房网
- 知识库--Using Akka Refs and Transactions(124)
- 学习笔记1--协方差矩阵
- 第四章:高级查询
- WEB入门之十六 操作DOM节点
- 第三章:SQL 编程
- docker简介及使用国内镜像源安装docker
- 第二章:数据库的实现
- 开源数据库最全盘点
- bzoj 4031: [HEOI2015]小Z的房间 (矩阵树定理+高斯消元)