On 8 Lis, 15:55, Anthony Lieuallen <[email protected]> wrote:
> On 11/8/2009 6:58 AM, Kodak wrote:
>
> > Hi all, I need to synch couple of tabs not to do same thing at the
> > same time so I need a semaphore. Is there a way to do a safe check and
> > change value in GM?
>
> Javascript in Firefox is single-threaded, so you don't need to worry
> about other scripts running, unless you specifically stop execution and
> continue later (via an ajax call, a setTimeout, event handler, etc).
>
> So, if you I.E. get a value (let's say a lock) that is false,
> immediately set it true and _then_ start doing your work (which can
> include the "stopping" methods mentioned above), no other script is
> going to execute between your get and set.

If Javascript is single-threaded then it is per window. I want to
synchronize couple of windows access to GM persistent properties
(preferences) being set using GM_setValue - would you agree that then
multiple simultaneous access to preferences can happen in the same
time then? Access to single GM functions like GM_getValue/GM_setValue
is probably serialized by firefox (is it?) but then I need to have a
function that gets and sets value in atomic transaction.
The best would be atomic function, something like
function GM_setValueIf(value, default, checkEqual)
which would set value only if current one equals checkEqual
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups 
"greasemonkey-users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/greasemonkey-users?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to