Scheduled reload of data feeds from Web Services
I have a doubt on what it can be the best practice to manage a set of feeds coming from the web in an application.
When the application starts I read in a configuration file received for first from a web query the expiration time of some feeds: these has a variable time depending on the content from some minutes to some hours or one or more days.
I have not the possibility to receive a notification from the web when a new update is available from the feeds so I should manage it as a scheduled reload.
The architecture I have in mind to implement this reducing as possible the application stress (and the number of timer used) is the following:
- Decide the shorter time unit (i.e. 60 secs)
- Create a timer based on it always running and repeating
- Every time I start a feed download I initialiaze a timer cycle counter (one different for every group of feeds)
- Every timer cycle I check what counters reach the max and if it is so I will update the feed and reset the corresponding counter.
Is this a good solution or there is some other method consuming less resources?
Can have sense to manage the feed updates following this way using and independent thread so that when the data are shown the user see always the last updated information ?
I'm not sure if I correctly understood your problem and if it would be the best solution but I would use QTimer::singleShot method to call the feed download method.
You can specify how often download the content by recalling QTimer::singleShot in your feed download method.
Hope it helps
sorry for the delay. yes it is the solution I aimed. My worry is if the timers spend too much resources or not. Consider that every feed will be updated on a different page so as a matter of fact there is always only one timer running (those of the page currently seen).