I was wondering what are the benefits of using an updatable read lock rather than the following steps:
Use read lockCheck the condition to see if we need to block the recordDisable read lockTake write lockPerform updateRecord Lock
One obvious drawback of performing the above steps, in contrast to setting an updated read lock, is that between steps 3 and 4 there is a time window where another thread can take a write lock.
Beyond this benefit, what other benefits will you find in order to take an updated read lock over the steps above?
-, " ".
, , 3 4 , . , 3 4, , 2.
, , :
, (, , ). , , . ( ).
, , 2, , , .
:
, 4 , , . , , , .
, , , , . , , , , .
, , , ( , ). , , - , .
, , , , - .
, , , .
, , , . , , , , . * , , .
, , , , , , .
* "-" , , , ints ReaderWriterLockSlim, , . , , .
ReaderWriterLockSlim
, , , , .