So... I have a few threads where data is originating, and two where it's being used. I'm reluctant to use producer/consumer because that's sort of implying this classical resource sharing pattern, but it's close to what I have.
What I want to do is make sure that when the source threads stack up mail in a mailbox, that the consumer can determine how old it is. More so, I can make sure it's not too out of date.
I can't be 100% certain when the information will get there, or when its sitting in mail when it'll get used. So let's say I want 100ms "keep alive" or timestamp or an "expired at" time.
There is clearly a way to do with this osGetTickCount, which I'd then have in the struct of the mail that's getting sent to my consumer thread. I could then look at it and figure out if too much time has passed.
Or would it be better for some reason to use a an osTimer? Start it when I make the request for data, and if I haven't received it all by the time the timer expires I know any data I did receive can be tossed out?
Is there a common way to do this?
Have each producer send an event when they have updated their data. And have them first set a time stamp for that data.
Let the consumer set a flag bit for every type of event it receives. When all bits are set - check all time stamps. If any time stamp is too old, clear those bits and back waiting for more events. If you do get a complete set of bits and finds all data to be fresh enough - perform a computation and clear all flags.
If you did find any of the data too old, then you could optionally update a blame counter for that producer. Verify if any blame counters ticks - then those producers aren't fulfilling their maximum 100ms production interval.
The above would then produce one output result per new data for the producer that is slowest (assuming that the producers are actually able to keep their realtime requirements so you don't get stalled by never getting a full set of data without some producer failing you).