I dunno. Every time a task start, they could increase a global variable TaskWaiting. Every time a task end, they increase a global variable TaskComplete.
The greasemonky script run at intervals, read these global variables and mantain the totalTaskWaiting and totalTaskComplete somewhere (maybe a central page, maybe with GM_setValue ). This greasemoneky script also mantain a variable globalTaskWaitingToComplete, with the number of task that have started, but are not finished, that is totalTaskWaiting - totalTaskComplete yadda.yadda.yadda... ugly stuff. The general idea is to use http://wiki.greasespot.net/GM_setValue to store data globally of the status. Then have the server send "Taks is starterd!" and "Task is finsished". It can be as comples or as simple as you want. You may want to save then ames of the task. so instead of saving a number, you save a list and mantain what one is finished or not, maybe other data like dependency, blocking/not blocking... PHP developers don't usually have to do anything like this, because the session storage they usually use block concurrent access, so B always wait until A end and closes. C waits for B to close. On 3 September 2014 16:54, brunoais <[email protected]> wrote: > I'm working on a script that, in order to reduce server load, should > synchronize between multiple instances that can appear in multiple pages. > > The idea is to have: > User opens tabs A,B,C,D. Each one has an instance of the script. > > The user start the processing in the tabs A, B, C, D (just assume about 1s > delay between each other and that they are in that order). > > The whole process to assist the user in gathering some data from the server > and from connections related to the server. > Multiple requests are required for each thing and that takes some time. > > In order to save on server load, my idea is to have B waiting for A to > finish, C waiting for B to finish and D waiting for C to finish. It is also > part of the idea to not rely on the server for this synchronization work as > it would use load to do some work that should be possible to do without the > server's intervention. > > My current problem is to synchronize all these so that D goes after C that > goes after B that goes after A. While not forgetting that if the tab B is > closed after A is complete, C should start (do not make infinite waits for B > to complete). Also, if B is closed while working, C starts working and D > continues to wait. > > I've been trying this with localstorage and the "storage" event and timeouts > (with also heartbeats) but I'm having issues with infinite loops and with > scripts running in the background. Any ideas? > > > Even if not true, please assume that there is no alternative to doing the > said requests to the server. > > -- > You received this message because you are subscribed to the Google Groups > "greasemonkey-users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > To post to this group, send email to [email protected]. > Visit this group at http://groups.google.com/group/greasemonkey-users. > For more options, visit https://groups.google.com/d/optout. -- -- ℱin del ℳensaje. -- You received this message because you are subscribed to the Google Groups "greasemonkey-users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at http://groups.google.com/group/greasemonkey-users. For more options, visit https://groups.google.com/d/optout.
