posted 17 years ago
Lek,
I considered the locking and synchronization as two related but different functions:
- synchronizing access to the RAF is needed for a single read, update, create, or delete operation, as you stated.
- the locking function ensures that no one else is modifying the specific record while one client is in the process of an update or delete (and I also locked the record during a create). Others may read the record while it is locked -- and because the RAF access is synchronized, the record's data will never be seen partially updated.
For example, when I want to update record 11 which is currently shown on the GUI, I do the following:
1. lock record 11
2. read the current data in record 11. This step also verifies the record is still active.
3. compare the current data to the data which was shown on the GUI. If the data is not the same, I send one of two exceptions depending on the difference (record is no longer eligible to be reserved; record is eligible to be reserved but some attributes have changed).
4. update record 11
5. unlock record 11
Note that the read in step 2 and the update in step 4 are synchronized, but I needed the lock function to ensure the data is not changed by another client between the read and update operations.
I hope this helps.
Cindy