Answer the question
In order to leave comments, you need to log in
What is the best way to implement resource counting?
Hello. Right now I have 2 columns for each resource.
--Max. quantity
-- current quantity
and common column for all
-- resource last recovery
time now I check how much has passed since the last recalculation and if more than 3 minutes have passed then I add n resources to the current quantity.
Interested in how you can optimize this business? Is there a better algorithm?
Answer the question
In order to leave comments, you need to log in
Implement this business on a timer. After all, you know exactly how much time from the current moment you need to increase the amount of resources. Start a timer that will raise the corresponding event. With t.z. performance - gain may be depending on the implementation of the timer. Well, the code will definitely become more beautiful.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question