3 ms·
Thanks for reading! I like this suggestion. The central problem of this post is not whether the timer is running continually. The central problem is how does t
by maxhallinan 8y ago
Thanks for reading! I like this suggestion.
The central problem of this post is not whether the timer is running continually. The central problem is how does the timer know when to stop/start making requests.
It's a problem because knowing this depends on access to information that is trapped in a different context. For example, the number of closed connections is only knowable within the context of the connection event handler. So how do you share this information with the timer?
One approach is to mutate global state. You move the information into a shared context where it's accessible everywhere. A second option, which is the focus of this post, is to look for better abstractions. In this case, those are abstractions over time. And when you have those abstractions, you can eliminate the global state.
- deleted 8y ago[deleted]
- mchahn 8y agoA question unrelated to your programming concepts: If you only query your source when a request comes in, doesn't the first requester get old data? This is a problem I have faced before.
- marvy 8y agoCouldn't you make the first requester wait until you've made your query?