Hi, you are facing a non-trivial synchronization problem. A lock is always a big problem in distributed systems because if the lock owner leaves, you can only recover using timers.
Furthermore, how do you select who maintains the rules? This ends up being a distributed consensus problem. In general, text books about "distributed systems" contain algorithms for distributed locks and distributed consensus. However, these algorithms are a) rather costly, i.e. slow b) as a wave gadget you cannot really send messages. Thus, applying the academic algorithms is inpractical. Instead, have a look at synchronization using logical clocks (scalar or vector clocks). I have done this for my gadget: http://code.google.com/p/secowela/wiki/Plany At this web site I have briefly discussed how the synchronization works. It requires no locks and no distributed consensus which is a big advantage,Perhaps this approach helps in your case, too. However, I agree with you that the current way of handling gadget state is rather a pain. For simple things like shopping lists or Yes/No/Maybe it is sufficient,but for more fine grained collaboration it is rather difficult to work with. Greetings Torben 2009/10/8 razorcam <i...@free2.eu.org> > > Hi, I am a gadget developper, and I am trying to add multiuser Wave > support to my "train your intelligence" gadget that you can test live > on my site www.razorcam.com . This is a realtime "game of life" with > a twist: the rules are unknown and hidden in a randomly generated > Javascript program at the start of each new game. > > This javascript program is "alive" thanks to a Javascript timer that > runs it frequently even if the user does nothing. > But in Gwave all the users will run this timer by default. So they > will all modify the board at the same time, generating conflicts. > > My solution is to have only one user run the rules, and to do so I > will use a synchronization variable (a lock, also called a semaphore) > stored in the wave state. This variable holds the time when the lock > was last applied so that other users can remove the lock if the owner > of the lock has gone away. There is a potential racing condition when > the lock is set thus a "sleep" maybe needed after the lock is set, in > order to test if another user tried to overwrite the lock. > > I hope that one day Gwave will offer a lock/semaphore mechanism for > synchronization in gadgets. > > The open source code is in Savannah, a project hosting service from > the Free Software Foundation, so that anyone can help this project: > http://git.savannah.gnu.org/cgit/intelligence.git/tree/ > > > > -- --------------------------- Prof. Torben Weis Universitaet Duisburg-Essen torben.w...@gmail.com --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Wave API" group. To post to this group, send email to google-wave-api@googlegroups.com To unsubscribe from this group, send email to google-wave-api+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/google-wave-api?hl=en -~----------~----~----~----~------~----~------~--~---