[sword-devel] Thread-safety in text rendering

Troy A. Griffitts scribe at crosswire.org
Mon Mar 3 11:14:05 MST 2014


Hi Костя,

Thank you for your comments. Threading discussions have come up many 
times over the life of the projects. We have cleaned the code up to help 
facilitate multithreading in the client. The general summary of the past 
discussions is: We try to make it safe to use different SWModule 
instances in different threads, but not the same SWModule instance in 
different threads. An SWModule performs work against the data files it 
represents. It would be similar in concept to an iterator which operates 
on its container. You can think of this way: you shouldn't use the same 
iterator in two different threads, but you can create multiple iterators 
against the container (as long as you aren't writing to the container :) 
), which is the same for us.

Searching is one task often performed in the background, especially 
non-lucene searching. These days a non-indexed search on any modern 
hardware should take less than a few seconds, but in the older days it 
would take longer, so this was often done in a separate thread in the 
background.

Anyway, in practice, projects usually keep one SWMgr around per thread, 
and then using the threading library of your choice for your platform. I 
believe we talked about adding a .clone() method on SWModule to make it 
easier to be streamlined.

The alternative is, as you suggest, try to incorporate some kind of 
cross-platform threading framework into the engine if we wanted to try 
to make some operations safe on the same SWModule object per thread, but 
I think conceptually we would be changing the paradigm for how SWModule 
is intended to be used.

Thoughts?

Troy




On 03/03/2014 05:01 AM, Костя Маслюк wrote:
> Hi, all.
>
> Welcome for your commentaries:
> www.crosswire.org/tracker/browse/API-166
>
> Blessings.
>
> _______________________________________________
> sword-devel mailing list: sword-devel at crosswire.org
> http://www.crosswire.org/mailman/listinfo/sword-devel
> Instructions to unsubscribe/change your settings at above page




More information about the sword-devel mailing list