I was hoping to use mstoolkit in a multi-threaded (with a private MSReader object per thread), but ran into issues. So far, I noticed the following needs to be changed:
[ ] Use strtok_s() (Windows) or strtok_r() instead of strtok(), as the latter uses a static buffer and is therefore not thread safe. See e.g. https://stackoverflow.com/a/54702249
[ ] The lLastScanIndex variable defined in mzParser.h is static. Moving this to a member variable of RAMPFILE seems like a proper solution.
So far, I quickly patched the above changes, and things seem OK. But at the moment I am also only using just the mzML part of the library. If more issues will arise, I will update this issue again.
Thanks,
Rick
edit1: I made the issue more generic for threading after noticing more issues.
Hello,
I was hoping to use mstoolkit in a multi-threaded (with a private
MSReader
object per thread), but ran into issues. So far, I noticed the following needs to be changed:strtok_s()
(Windows) orstrtok_r()
instead ofstrtok()
, as the latter uses a static buffer and is therefore not thread safe. See e.g. https://stackoverflow.com/a/54702249lLastScanIndex
variable defined inmzParser.h
is static. Moving this to a member variable ofRAMPFILE
seems like a proper solution.So far, I quickly patched the above changes, and things seem OK. But at the moment I am also only using just the mzML part of the library. If more issues will arise, I will update this issue again.
Thanks, Rick
edit1: I made the issue more generic for threading after noticing more issues.