JCL Help:TJclMultiReadExclusiveWrite.BeginWrite

From Project JEDI Wiki
Jump to navigationJump to search


Summary

Allows a thread write-access to the protected resource, blocking until the access can be granted.


Pascal

 public procedure BeginWrite;


Description

BeginWrite allows a thread to gain write-access to the protected resource. This method will block the calling thread until write-access can be granted. After a thread has been granted write-access, all other threads requesting access, either read or write, will be denied access until the thread currently holding write-access calls EndWrite. Note that it is legal to request read-access while holding write-access, however, the thread will not be granted read-access, instead its recursion count is incremented and write-access is preserved. It is safe to call BeginWrite while already holding write-access, it merely increments a recursion count. If you call BeginWrite multiple times you must also call EndWrite multiple times. That is, the calls to BeginWrite and EndWrite must be balanced.


See Also

EndRead BeginRead EndWrite


About

Donator

Marcel van Brakel


Notes

Warning! Calling BeginWrite while the thread already owns a read lock causes the thread to temporarily give up it's read lock altogether. Therefore it is not safe to assume that the resource is unchanged when you "promote" a read lock to a write lock. This is necessary to prevent a dead lock situation where two threads both attempt to promote a read lock.


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