I currently have a costly function (I already tried to optimise it as much as possible) and it needs to be called every time some random event happens, this creates 2 problems:
1) If the even happens (for example) 3 times in a row, the first two executions are going to be in the way, I thought using NSOperation to cancel every old execution and then start a new one so I'll always have the updated result, but that would create problem number 2
2) If during a period of time, the even happens regularly... I'll be always canceling old executions and the user will never see a result until the even stops happening for a while
What would be your suggestion for handling a situation like this?