questions about mozSettings.createLock()

This is an OpenPGP/MIME signed message (RFC 4880 and 3156)
--TM5dHfusFuefKBxNXLG87rBoxHXbiLLmi
Content-Type: text/plain; charset=utf-8
Content-Transfer-Encoding: quoted-printable

Hey,

I have some questions about how mozSettings.createLock is supposed to wor=
k.

Example 1:

var lock =3D mozSettings.createLock();
var req =3D lock.get('bluetooth.enabled');
req.onsuccess =3D function() {
  // result in req.result['bluetooth.enabled']
};


This case is quite straightforward, no question.


Example 2:

// assume alarm.enabled is set to false.
var lock1 =3D mozSettings.createLock();
lock1.set({'alarm.enabled': true});

var lock2 =3D mozSettings.createLock();
var req2 =3D lock2.get('alarm.enabled');
req2.onsuccess =3D function() {
  // result in req2.result['alarm.enabled'] -> true ?
};


Given what I read in MDN, I think this is quite well specified too.
Requests on lock2 will run after requests on lock1 run.


Example 3:

// assume alarm.enabled is set to false.
var lock1 =3D mozSettings.createLock();
lock1.get('bluetooth.enabled');
lock1.set({'alarm.enabled': true});

var lock2 =3D mozSettings.createLock();
var req2 =3D lock2.get('alarm.enabled');
req2.onsuccess =3D function() {
  // result in req2.result['alarm.enabled'] -> true ?
};

=46rom my understanding, the same happens here.


Example 4:

// assume alarm.enabled is set to false.
var lock1 =3D mozSettings.createLock();
var req1 =3D lock1.get('bluetooth.enabled');
req1.onsuccess =3D function() {
  // result in req1.result['bluetooth.enabled']
  lock1.set({'alarm.enabled': true});
};

var lock2 =3D mozSettings.createLock();
var req2 =3D lock2.get('alarm.enabled');
req2.onsuccess =3D function() {
  // result in req2.result['alarm.enabled']
};


So here I'm not sure: because the second operation on lock1 runs in the
first operation's callback: are they run on the same transaction, or is
it effectively the same as having a 3rd lock in req.onsuccess callback?


Example 5:

// assume alarm.enabled is set to false.
var lock1 =3D mozSettings.createLock();
var req1 =3D lock1.get('bluetooth.enabled');
req1.onsuccess =3D function() {
  // result in req1.result['bluetooth.enabled']

  var req =3D lock.get('alarm.enabled');
  req.onsuccess =3D function() {
    // result in req.result['alarm.enabled']
  };
};

var lock2 =3D mozSettings.createLock();
var req2 =3D lock.set({'alarm.enabled': true});


Similar than the 4th example, and same question.


So I'm not asking what happens currently in Firefox OS, but what is
supposed to happen.

Thanks !
--=20
Julien


--TM5dHfusFuefKBxNXLG87rBoxHXbiLLmi
Content-Type: application/pgp-signature; name="signature.asc"
Content-Description: OpenPGP digital signature
Content-Disposition: attachment; filename="signature.asc"

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1

iQIcBAEBAgAGBQJUxoC2AAoJEHjtma/kG/DBAuYQAIz3g6ZfFc1dtbJapd/omAtY
PyqX4ThTTt53H86Ohmx9p4FEmpLpzHpPVfaYI5yTx5oO0ErWTey9U+2+HF+40WYa
PVRh/K7aeIM8+Dz/r0Lwin9EtsQ0KGe4Cf3CEeqQIKVMuLOkwjYbpgjN6WFY/rgs
rNa0deUEahfjfBLWooogJj2rzMCOOIzZB4UeIkTqJUO+19QCXg1uydjaMD3uZiII
iwvlMVmj1MPlqgbFSBnUkLOBXlFjWFSc8xN7+CLwHk9MiJRwoZkYYapg3Akl1MLz
7IyrKs+DDTu3lDKkJ+V+bQ82oucISmBeCrJA3LBodOboHTCNWZ1aGmEgNke49zz8
NfLbdew3AXLFA3WbfV4G4EInU885OJw5UYO7DGscI2f5osqyijfPUex+zHvypVmG
rwOL9nfAnUrDhCMkDf13tHtNcXUB8uKXWz9dcd4x6HjRic5XQbZ9HAdiEasqwjj3
tjsVrmQSeDMOADXxvCmcnebVtuL5nWYZFfg8bYZ6LYFw302FdjnzqZStccVP0lRe
1i2NpQUNWS49SqT4cDljH26lTPrKWfjka2aF6lzyVREUfLdmnR/YQUVts0zstbNS
pOsCYEdaObwUyR722X652MBmgUjAvpJXAM2X0hx9hTeWeji1FE+T4UrjJn24felR
4X5kwSSCv9EQgc4URCtQ
=bMHh
-----END PGP SIGNATURE-----

--TM5dHfusFuefKBxNXLG87rBoxHXbiLLmi--
0
Julien
1/26/2015 6:00:22 PM
mozilla.dev.webapi 565 articles. 0 followers. Post Follow

1 Replies
1423 Views

Similar Articles

[PageSpeed] 46

On Monday, January 26, 2015 at 10:00:38 AM UTC-8, Julien Wajsberg wrote:
> Hey,
> 
> I have some questions about how mozSettings.createLock is supposed to work.
> 
> Example 1:
> 
> var lock = mozSettings.createLock();
> var req = lock.get('bluetooth.enabled');
> req.onsuccess = function() {
>   // result in req.result['bluetooth.enabled']
> };
> 
> 
> This case is quite straightforward, no question.
> 
> 
> Example 2:
> 
> // assume alarm.enabled is set to false.
> var lock1 = mozSettings.createLock();
> lock1.set({'alarm.enabled': true});
> 
> var lock2 = mozSettings.createLock();
> var req2 = lock2.get('alarm.enabled');
> req2.onsuccess = function() {
>   // result in req2.result['alarm.enabled'] -> true ?
> };

Correct. The read operation of lock 2 is executed after the write of lock 1.

> 
> 
> Given what I read in MDN, I think this is quite well specified too.
> Requests on lock2 will run after requests on lock1 run.
> 
> 
> Example 3:
> 
> // assume alarm.enabled is set to false.
> var lock1 = mozSettings.createLock();
> lock1.get('bluetooth.enabled');
> lock1.set({'alarm.enabled': true});
> 
> var lock2 = mozSettings.createLock();
> var req2 = lock2.get('alarm.enabled');
> req2.onsuccess = function() {
>   // result in req2.result['alarm.enabled'] -> true ?
> };
> 
> From my understanding, the same happens here.

Yep.

> 
> 
> Example 4:
> 
> // assume alarm.enabled is set to false.
> var lock1 = mozSettings.createLock();
> var req1 = lock1.get('bluetooth.enabled');
> req1.onsuccess = function() {
>   // result in req1.result['bluetooth.enabled']
>   lock1.set({'alarm.enabled': true});
> };
> 
> var lock2 = mozSettings.createLock();
> var req2 = lock2.get('alarm.enabled');
> req2.onsuccess = function() {
>   // result in req2.result['alarm.enabled']
> };
> 
> 
> So here I'm not sure: because the second operation on lock1 runs in the
> first operation's callback: are they run on the same transaction, or is
> it effectively the same as having a 3rd lock in req.onsuccess callback?

You can assume that all operations for a specific lock are atomic. The usual gate-keeper is the event loop. Callbacks also work. All lock1 requests run before lock2 requests in your example.

> 
> 
> Example 5:
> 
> // assume alarm.enabled is set to false.
> var lock1 = mozSettings.createLock();
> var req1 = lock1.get('bluetooth.enabled');
> req1.onsuccess = function() {
>   // result in req1.result['bluetooth.enabled']
> 
>   var req = lock.get('alarm.enabled');
>   req.onsuccess = function() {
>     // result in req.result['alarm.enabled']
>   };
> };
> 
> var lock2 = mozSettings.createLock();
> var req2 = lock.set({'alarm.enabled': true});
> 
> 
> Similar than the 4th example, and same question.

The same rule applies here. Requests in callbacks can be chained.
Lock2 comes afterwards.

> 
> 
> So I'm not asking what happens currently in Firefox OS, but what is
> supposed to happen.
> 
> Thanks !
> -- 
> Julien

0
Gregor
1/26/2015 9:03:20 PM
Reply:

Similar Artilces:

windows ME questions, questions, questions.......
Hi, my next PC will be running Windows ME. The PC will be supplied via my work, so there's no choice here for me (ME?) (I think I would have preferred 98 SE). The harddisk (40GB matrox) will have ME installed, and both the Windows ME set-up files and an image of the initial Harddisk 'on a hidden partition'. Word has it that this partition is not seen by Format nor FDisk. Is this really possible? No Windows CD will be supplied. Seems a new way of MS to encourage working with licensed software only. Anyone familiar with this way of distributing an OS? Will I be able to ...

Question about questions
Name: Edward Newill Email: ernewillatyahoodotcom Product: Thunderbird Summary: Question about questions Comments: Is there an email address that I can send a question too? I could not find one in the Service area of your site. I would like to know how I create signatures for my Thunderbird email? Best regards, E. Newill Browser Details: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; .NET CLR 1.1.4322; .NET CLR 2.0.50727) From URL: http://hendrix.mozilla.org/ ...

Consolidating dev-webapi into dev-platform after Friday (2015-06-19)
Unless you have serious objections, I'm going to request that dev-webapi redirects to dev-platform as of this coming Saturday at 00:00. A few people have pointed out that having the split mailing list is causing confusion about where to send emails and the traffic level doesn't seem to me to justify its continued existence. ...

Dev Env. Questions...
Ok, this is a bit stupid BUT I'm stumped! Created as Class Library in the DotNetNuke.DesktopModules solution for a new custom module etc. no prob. Created a tempcontrols folder in DNN project then move the controls into the Class Library project. no prob. In this way I created a few user-controls to be used in parent controls. NOW, try to add one user control to a parent control, it does not display a UserControl "box" on the parent control but puts a link/path to the control. If this is done in a Web App project the UserControl "box" is displayed, no prob. BUT doing this within ...

A question on the dev process
Hi, I am registered to a bunch of bugmail components and for the web APIs, I notice a lot of "develop tests for X". I'm somewhat surprised by these emails, because I thought tests were developed as part of write the code for a feature. Is there a particular reason for separating feature and tests? David On Thursday, November 22, 2012 5:53:30 AM UTC+8, David Bruant wrote: > Hi, >=20 > I am registered to a bunch of bugmail components and for the web APIs, I= =20 > notice a lot of "develop tests for X". I'm somewhat surprised by these=...

Question for YAST devs...
I'm going to be building a desktop app and we're looking at using HTML//javascript/css for the GUI but we're not sure of the best way to do this and map it up with c++/Java code. We know (believe) that the new YAST uses an HTML front-end and we're wondering if someone could give us some ideas as to what was doen in YAST. Thanks! -- 6tr6tr ------------------------------------------------------------------------ 6tr6tr wrote: > we're wondering if someone could give us some ideas as to what was > doen in YAST. as a matter of routine there are ...

[QUESTION] this is a menu question ;-)
i'd like to know if it is possible to build dynamically a menu ? Let me explain : if i create as many menu items as i need, is it possible then to create a menu made of selected menu items. for example, i create three menu items : m_open m_save m_close then in one of my sheet, i just need m_open and m_close, is it possible to create, dynamically, a menu m_file which is made of m_open and m_close ? meaning that the Item property is not read-only... thanks a lot for any answer ! Guillaume MAISON Not a practical approach in PowerBuilder. You would be better off u...

Merging dev-gaia and dev-b2g into dev-fxos
--001a113ce93ebce35d051e4c0c73 Content-Type: text/plain; charset=UTF-8 Hello people of Firefox OS, After a discussion we have decided that the distinction between dev-gaia and dev-b2g mailing lists is not enough to warrant maintaining two lists. So we are deprecating both in favor of dev-fxos. So if you are subscribed to one of the aforementioned lists, you will be subscribed to the new dev-fxos list and we will shortly be decommissioning dev-gaia and dev-b2g. Thanks! Michael --001a113ce93ebce35d051e4c0c73 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: qu...

Merging dev-gaia and dev-b2g into dev-fxos
--001a113ce93ebce35d051e4c0c73 Content-Type: text/plain; charset=UTF-8 Hello people of Firefox OS, After a discussion we have decided that the distinction between dev-gaia and dev-b2g mailing lists is not enough to warrant maintaining two lists. So we are deprecating both in favor of dev-fxos. So if you are subscribed to one of the aforementioned lists, you will be subscribed to the new dev-fxos list and we will shortly be decommissioning dev-gaia and dev-b2g. Thanks! Michael --001a113ce93ebce35d051e4c0c73 Content-Type: text/html; charset=UTF-8 Content-Transfer-Encoding: qu...

newbie question
i'm planning to writing an XPCOM component is javascript. 1. how does javascript know to call the NSGetModule() method when a file is loaded. it always does it? 2. if i'm writing some code in c++, i assume i have to compile it for different platforms. does this result in different platform specific extension (.xpi) files or is it one file and the loader figures out the right version (i.e. subfoler) to load based on platform. 3. is there an online source for detailed docs on all the components and interfaces. thx. dashman wrote: > i'm planning to writin...

A couple of extension dev questions
I have a couple of questions (related to feasibility) for a Thunderbird extension I am working on. 1) Can a new column be added to the message list view? All I need to slot in there is an icon for particular messages. If not, can I slot the icon in a column in any particular message, e.g. to the left of the subject. My guess is to apply a property to the tree row and add a CSS rule for it. 2) Can .eml files on disk, when opened, be added to the Inbox, or any particular folder? Thanks, -- Brian King www.mozdev.org - free project hosting for the Mozilla community Brian...

Renaming mozSettings getLock() to createLock()
Please note that we are renaming mozSettings.getLock() to = mozSettings.createLock(). Bug 788561 should be landing on inbound soon. The reason is that we heavily use a bad pattern especially during = starting the phone and applications. Calling getLock or now createLock creates a transaction for indexedDB = and this results in creating a new thread (until a certain threshold). We do this heavily during startup and it definitely hurts our startup = performance. Please use a single lock for get/set settings if possible. So instead of many calls like mozSettings.getLock().set(=8...

Module Dev Questions for DNN3
1> I am trying to reference an external JavaScript file located in a script subdirectory .. underneath my modules main folder. I can reference with a complete path. .. .. ie. http://www.domain/desktopmodules/mymodule/scripts/jsfile.js .. .. I have seen relative references for dnn2 like the following: .. ~/desktopmodules/mymodule/jsfile.js and .. /desktopmodules/mymodule/jsfile.js Neither of these work for me. Any help on this?? 2> How should I reference the controls in my ascx page. .. If I have a panel for example named Pan...

visual web dev. question
does visual web developer 2005 come with the installation of visual studio 2005 professional??? And do you have to have windows XP professional in order to download the sql server express edition?? Hi, no VWD is an IDE that ships on its own and is the free "version" of vs.net 2005 (which has more features). VWD ships with it's own built in webserver, only localhost's supported, so you should be able to use Windows XP Home edition too. Grz, Kris.Read my blog. Handy Firefox plugins for web developers.Workaround for non working Mark as answer buttons. Something which may be worth poiting...

Web resources about - questions about mozSettings.createLock() - mozilla.dev.webapi

JSDoc: Home
Currently basic settings services (mozSettings/UI bindings, panel navigation...) used across the app and root panel specific logic are defined ...

Resources last updated: 12/7/2015 10:48:42 PM