I have a vector that is constantly being updated (about 5-20 times a second) with new information by a process that I wrote to gather the information. I want to write a loop that would be able to detect a change in the vector, and then read the information and do the appropriate analysis that I write for that event. However, I know that there are many issues that arise from multithreading like this, so I’m curious what the best ways to do something like this are.
The vector is stored in a public class and is being updated by a feed we get from a financial company (the information being updated is futures indices).
I don’t see a way to do this in C++. If you used shared memory you could store the
vectorin it, but its components would still be pointing at local, non-shared memory chunks, preventing it from being shared (you might be able to work around with with allocator trickery but I’m not sure it would work).boosthas some shared memory capabilities but as I recall from a question I can’t find it has some downsides. You’ll most likely have to design your own shared memory data structure and provide a mechanism to store a condition variable there so clients can wait on it to determine when new data is available.EDIT: I found the question asking about
boost::interprocess:Is boost::interprocess ready for prime time?