JCL Help:TJclMultiReadExclusiveWrite

From Project JEDI Wiki
Jump to navigationJump to search

Class Hierarchy

TJclMultiReadExclusiveWrite


Summary

Allows multiple readers but only one writer.


Pascal

 public TJclMultiReadExclusiveWrite = class(TObject);


Description

TJclMultiReadExclusiveWrite is a synchronization object similar to a critical section. It protects some resource by controlling access to it. Unlike a critical section however, a TJclMultiReadExclusiveWrite allows multiple threads access to the protected resource. The threads that request access are separated into two logical groups called Readers and Writers. The class allows only one writer to have access to the resource at any time. All other threads, both readers and writers must wait until the resource is released. Readers however can access the resource simultaneously. When one or more readers have been granted access, all writers are blocked. The distinction between readers and writers is made based on how the threads request access to the resource. Readers use the BeginRead and EndRead methods while Writers use BeginWrite and EndWrite. It is up to the application to define what readers and writers really are. In addition to the above, the class allows readers to be promoted to writers and it allows the application to tune the access. If you so wish you can have the class favor readers over writers, vice versa or treat them equally. Note that if you have the class favor one over the other than the 'other' may never get access to the resource depending on the details of your application and pure coincidence (due to timing issues which are beyond control of the class). Note that the implementation of this class was inspired mainly by Jeffrey Richters CMREW class presented in his book "Programming applications for Microsoft Windows, 4th edition".


About

Unit

JclSynch


Navigation

Donator

Marcel van Brakel


Contribute to this help topic

This documentation wiki is based on the collaborative effort of Project JEDI users. Your edits are welcome in order to improve documentation quality: edit this page