the wrappedJSObject hack and thread safety
Hello ---
I'm new to looking at Zotero, and am interested in using the data API for another extension I'm writing. I greatly appreciate the well written documentation you've already done for this, but there's a fundamental concept that isn't quite clicking for me. I'm at least superficially familiar with the concepts involved (XPCOM services, SQLite thread safety, and SpiderMonkey) but I'm ignorant of many implementation details.
Here's where I'm stuck:
http://developer.mozilla.org/en/docs/Storage pretty much says that there is no safe way to access a database from multiple threads. I thought the solution would be a service running in a proxy thread that does all the access to the database, but from a superficial glance at your (clear and well-commented) code it seems like you aren't doing anything like that. In fact, giving direct access to the wrappedJSObject seems like it would make this impossible.
Is this safe because there is a proxy occurring at the mozIStorageService level that I haven't discovered yet? Or perhaps because (according to some vague memory I have) that all JavaScript runs from a single thread, is thus will be automatically thread safe? Is there maybe some other locking that happens at the Zotero level that I didn't notice?
Thanks for any information!
I'm new to looking at Zotero, and am interested in using the data API for another extension I'm writing. I greatly appreciate the well written documentation you've already done for this, but there's a fundamental concept that isn't quite clicking for me. I'm at least superficially familiar with the concepts involved (XPCOM services, SQLite thread safety, and SpiderMonkey) but I'm ignorant of many implementation details.
Here's where I'm stuck:
http://developer.mozilla.org/en/docs/Storage pretty much says that there is no safe way to access a database from multiple threads. I thought the solution would be a service running in a proxy thread that does all the access to the database, but from a superficial glance at your (clear and well-commented) code it seems like you aren't doing anything like that. In fact, giving direct access to the wrappedJSObject seems like it would make this impossible.
Is this safe because there is a proxy occurring at the mozIStorageService level that I haven't discovered yet? Or perhaps because (according to some vague memory I have) that all JavaScript runs from a single thread, is thus will be automatically thread safe? Is there maybe some other locking that happens at the Zotero level that I didn't notice?
Thanks for any information!
This is an old discussion that has not been active in a long time. Instead of commenting here, you should start a new discussion. If you think the content of this discussion is still relevant, you can link to it from your new discussion.
Upgrade Storage
A lot may be changing with respect to threads in Firefox 3, so it's possible there will be additional issues in the future.
Some useful information (and links to more such information) is here:
http://www.neilmix.com/2007/02/14/what-mean-you-threads/
The impression I got is that FF3 will almost definitely remain the same.