Pending changes

Events happening in the community are now at Drupal community events on www.drupal.org.
ernestd's picture

A means used in the server side to manage the concurrency is the use of pending changes list. I'm sure any top coder can improve (even laught at) the code so I'll explain how it works so it can be improved in the future:

Usually when one hears about collaborative edition one thinks the most difficult part is to handle when two users are writing content at the same time. And this is not true. The user who is accessing the server is going to read the data is stored even if another user is accessing 0,1 seconds later to store new data. The problem of concurrency is that a user should work on the last common version of the document even if the last version has been uploaded by another user 20 seconds before.
Therefore we need to make it happen. But keep in mind the simulteanity is not the big issue in this story.

The scenario is easy to explain:
I'm a user who's got last time from the server It's raining here and I modify it to It's raining a lot here.
The words a lot have been inserted in the position 13. The only thing the server needs to do to have the content updated is insert a lot in the position 13 of the string.

But, if there have been other users who have inserted new content since I got the first content, for example, It's not raining here. Then, I haven't been working on an updated version of the content and when i upload my new text the server need to fix it and it should insert a lot in the position 17. This is the word not (4 characters) plus the my original start position (13). This way, the server will have the common version. Notice that we only bother that content inserted before my caret position and not after. So, it's a good thing we have the diff text in only one block extracted in the client side (See Get the diff)

To summ up, the server will need to add up to my insert start position the length of all those changes made by other users since my last access to the server, thus it keeps a list of all these changes ready to implement next time i access to the server and then flush this list once i'm done.
Further information: Use cases

SoC 2006: Collaborative Editor

Group organizers

Group notifications

This group offers an RSS feed. Or subscribe to these personalized, sitewide feeds: