Currently we create one upfront and then re-use it. This means that if the same detector is used from multiple threads, weird things could happen.
There doesn't appear to be a noticeable performance benefit to creating this working space upfront (tested on my desktop, not a pi), so I'm inclined to suggest that we shouldn't bother doing so.
I'm not sure whether the detector logic itself is thread-safe, so if it's not then we should probably look at adding locks instead of bothering with this approach.
Currently we create one upfront and then re-use it. This means that if the same detector is used from multiple threads, weird things could happen.
There doesn't appear to be a noticeable performance benefit to creating this working space upfront (tested on my desktop, not a pi), so I'm inclined to suggest that we shouldn't bother doing so.
I'm not sure whether the detector logic itself is thread-safe, so if it's not then we should probably look at adding locks instead of bothering with this approach.