<div dir="ltr">Hi,<div><br></div><div>The ticket about thread safety exactly describes the problems I am seeing :)</div><div><br></div><div>The code is this:</div><div><br></div><div><div><span style="line-height:1.5"> sword::SWMgr manager (sword_logic_get_path ().c_str ());</span><br></div><div><span style="line-height:1.5"> sword::SWModule *module = manager.getModule (module_name.c_str ());</span><br></div><div> if (module) {</div><div> string key = osis + " " + convert_to_string (chapter).c_str () + ":" + convert_to_string (verse).c_str ();</div><div> module->setKey (key.c_str ());</div><div><span style="line-height:1.5"> rendering = module->renderText();</span><br></div><div><span style="line-height:1.5"> }</span><br></div><div><br></div></div><div>Indeed, the crashes relate to "setKey" and "renderText", and not to "SWMgr".</div><div>But I am happy to surround the entire block with a mutex, and it's working fine :)</div><div>Thank you for all your hard work!</div><div><br></div><div>Teus.</div></div><br><div class="gmail_quote"><div dir="ltr">On Mon, 11 Jan 2016 at 17:33 Troy A. Griffitts <<a href="mailto:scribe@crosswire.org">scribe@crosswire.org</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div>Hi Teus,<br>
<br>
Yes, as Greg has pointed out, we've done our best to make it easy to perform multitheaded operations with the library by allowing you to instantiate a new SWMgr for each thread. We don't use threading libraries ourself inside the engine to lock critical sections but instead we tried to avoid critical sections within one instance of an SWMgr. We allocate a distinct instance of SWMgr per thread in many of our friends, e.g., one SWMgr for display and one for search so we can search in a separate thread.<br>
<br>
With a standard threading mechanism included in C++11 we might consider conditionally compiling in support to assure some iffy common sections of code are in fact safe. I am specifically thinking of junk buffers in SWBuf (but I think we cleaned those up) and also FileMgr, which handles closing and reopening file handles at the system level when resources are tight.<br><br><div class="gmail_quote"></div></div><div><div class="gmail_quote">On January 11, 2016 5:52:58 AM MST, Teus Benschop <<a href="mailto:teusjannette@gmail.com" target="_blank">teusjannette@gmail.com</a>> wrote:</div></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr">Hi,<div><br></div><div>When accessing libsword simultaneously from multiple threads, it often crashes. When surrounding the calls to the library with a mutex.lock and a mutex.unlock at the end, there's no crashes when accessing it in the same situation. I am seeing this on Linux and on the Mac. Should I do something in the library, or make a special call, to make it thread-safe? Or is surrounding the library calls with a mutex the recommended way to handle this?</div><div><br></div><div>Teus.</div></div>
<p style="margin-top:2.5em;margin-bottom:1em;border-bottom:1px solid #000"></p></blockquote></div></div><div><div class="gmail_quote"><blockquote class="gmail_quote" style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><pre><br>sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br><a href="http://www.crosswire.org/mailman/listinfo/sword-devel" target="_blank">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>Instructions to unsubscribe/change your settings at above page</pre></blockquote></div></div><div><br>
-- <br>
Sent from my Android device with K-9 Mail. Please excuse my brevity.</div>_______________________________________________<br>
sword-devel mailing list: <a href="mailto:sword-devel@crosswire.org" target="_blank">sword-devel@crosswire.org</a><br>
<a href="http://www.crosswire.org/mailman/listinfo/sword-devel" rel="noreferrer" target="_blank">http://www.crosswire.org/mailman/listinfo/sword-devel</a><br>
Instructions to unsubscribe/change your settings at above page</blockquote></div>