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?
(especially formerly) a student appointed to assist in the conduct of a class or school, as to help take attendance or keep order. a person appointed to supervise students, applicants, etc., taking an examination, chiefly to prevent cheating; proctor.
A class monitor is responsible for passing out papers in their classroom, take attendance, and clean up after classes have ended. They are also expected to provide feedback on how things could be improved at school assemblies or other school events that they attend with their teachers.
The incumbent in this class is responsible for the supervision of students and student activities and for maintaining order in school buildings, school district public libraries, on school grounds and playgrounds, and at street crossings.
A class monitor is a student who assists the teacher in routine duties. They maintain class discipline in the teacher's absence and lead the class through various activities. They should act as a role model for the rest of the students.
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With