English 中文(简体)
可变数据和锁定
原标题:Immutable data and locking

是否有理由为(否则的话)不可改变的数据提供一种锁定机制?

最佳回答

Typically, no. One of the major advantages of using immutable data is that you can avoid locking, as you have an implicit guarantee that the data is "current" and nobody, including you, can modify it.

问题回答

在某些情况下,如果这种接口的某些实施可能需要锁定,则最好是有一种仅读的界面提供“检索”方法。 采用接口的不可变物体不一定要根据AcquireReadLock的要求做任何事情,但必须至少为这种方法提供不全的执行;这种方法的使用者在试图完成一系列可能产生不希望结果的读物之前,会要求AcquireReadLock使用,如果其他一些人对标语进行变换(即使该标语能够用只读的界面更改,也意味着通过其他手段改变标语。 此外,即使用其他方式可变的物体不需要锁定,它仍可能希望选择“模拟”锁定,以便确认该物体的消费者能够适当获取和释放锁。

不是说它确实是完全不可改变的。





相关问题
XML-RPC Standard and XML Data Type

I was looking at XML-RPC for a project. And correct me if I m wrong, but it seems like XML-RPC has no XML datatype. Are you supposed to pass as a string? or something else? Am I missing something? ...

Is it exists any "rss hosting" with API for creating feeds

I am creating a desktop app that will create some reports. I want to export these reports as RSS or ATOM feeds. I can easily create feeds with Rome lib for Java. But I have no idea how to spread them. ...

Improving Q-Learning

I am currently using Q-Learning to try to teach a bot how to move in a room filled with walls/obstacles. It must start in any place in the room and get to the goal state(this might be, to the tile ...

High-traffic, Highly-secure web API, what language? [closed]

If you were planning on building a high-traffic, very secure site what language would you use? For example, if you were planning on say building an authorize.net-scale site, that had to handle tons ...

Def, Void, Function?

Recently, I ve been learning different programming langages, and come across many different names to initalize a function construct. For instance, ruby and python use the def keyword, and php and ...

热门标签