[sword-devel] SWORD multi-session/thread support
manfred.bergmann at me.com
Sun Aug 1 03:20:30 MST 2010
Hmm, I couldn't find a clone() method in SWModule.
Let me know if it has to be there and I will look again.
Am 30.07.2010 um 09:47 schrieb Troy A. Griffitts:
> Yes Manfred, SWModule can be seen as an iterator over a set of data.
> If you wish to have two different states of iteration then you need two
> instances. There are methods for this and two different predominant
> ways to handle it in your app. Example scenario below-- display and search:
> SWMgr library;
> SWModule *bookForDisplay = library.getModule("KJV");
> // display
> SWModule *bookForSearch = bookForDisplay->clone();
> // do my search
> delete bookForSearch;
> SWMgr libraryForDisplay;
> SWMgr libraryForSearch;
> SWModule *bookForDisplay = libraryForDisplay.getModule("KJV");
> SWModule *bookForSearch = libraryForSearch.getModule("KJV");
> // do my search
> Hope this gives some ideas,
> On 07/30/2010 12:54 AM, Manfred Bergmann wrote:
>> Vadim's question in sword-support made me think a little.
>> SWMgr being or used as a singleton is fine. Somewhere there is always as synchronisation point.
>> But if I'm not mistaken the modules you get via the list are all the same instances. I mean, suppose there are two threads, each retrieve the same module from SWMgr.
>> They do both retrieve the same module instance, don't they?
>> Now if both want to iterate over the module this will cause problems. In MacSword/PocketSword we use semaphores to lock the modules so that no two threads can position and pull text at the same time. This however is very bad for multi-threaded environments like a web application is.
>> Is there a way to retrieve different instances of modules from SWMgr? Or can there be multiple instances of SWMgr?
>> sword-devel mailing list: sword-devel at crosswire.org
>> Instructions to unsubscribe/change your settings at above page
> sword-devel mailing list: sword-devel at crosswire.org
> Instructions to unsubscribe/change your settings at above page
More information about the sword-devel