Hi Mike,
I have a proposed fix that fixed all my multi-threading issues with the C++ target.
In IntervalSet.cpp, it involves guarding with a mutex all functions modifying the _intervals member.
The runtime performance hit is negligible and it prevents all crashing.
Note I'm getting a speedup that is linear with the number of threads by splitting the files to parse appropriately and scheduling the pieces evenly in between threads.
static std::mutex mutexInt;
IntervalSet::IntervalSet(int n, ...) : IntervalSet() {
std::lock_guard<std::mutex> lg(mutexInt);
va_list vlist;
va_start(vlist, n);
for (int i = 0; i < n; i++) {
add(va_arg(vlist, int));
}
}
......
void IntervalSet::clear() {
std::lock_guard<std::mutex> lg(mutexInt);
if (_readonly) {
throw IllegalStateException("can't alter read only IntervalSet");
}
_intervals.clear();
}
......