D班班长是什么?
D2.0 类有一个 __monitor
类属性,该属性“提供对类对象监视器的访问”(文档)。我搜索了一下,除了这个位之外没有找到任何信息的细节。那么:什么是显示器?为什么一台监视器用于所有同步成员函数?它是一个类似于Java的用于同步成员函数的同步原语吗?如果您不应该使用 __monitor
属性,为什么它会出现在语言定义中/用例是什么?
D2.0 classes have a __monitor
class property that "gives access to the class object's monitor" (documentation). I searched around a bit and did not find any information except for this bit of detail. So: what is a monitor? Why is one monitor used for all synchronized member functions? Is it a synchronization primitive used for synchronizing member functions similar to Java? And why is the __monitor
property in the language def if you are not supposed to use it / what are the use-cases?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
监视器是一个延迟初始化的对象,所有同步方法都在其上同步,就像在 Java 中一样。与 Java 不同,D 是一种系统编程语言,它公开了事物如何工作的较低级别细节,以防您需要破解它们,即使这样做通常是一个坏主意。这允许您自定义行为。例如,可以自定义类的监视器对象,或者使用与拥有该监视器的类共享监视器的
core.sync.mutex
。The monitor is a lazily initialized object that all synchronized methods synchronize on, just like in Java. Unlike Java, D is a systems programming language and exposes lower level details of how things work just in case you need to hack them, even if doing so is usually a bad idea. This allows you to customize behavior. For example, it is possible to customize the monitor object of a class, or to use a
core.sync.mutex
that shares a monitor with the class that owns it.