D班班长是什么?

发布于 2024-08-23 19:16:05 字数 554 浏览 4 评论 0原文

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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

孤寂小茶 2024-08-30 19:16:05

监视器是一个延迟初始化的对象,所有同步方法都在其上同步,就像在 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文