Shouldn't a (thread safe or manually locked) stack data structure work? Because its nature is "last in/first out" which is what you want. Requests go on the stack. When it's time to work on the next request, you always pop the newest one from the stack and then empty the stack (thus discarding the obsolete requests) in an atomic (i.e. synchronized) single action.
↧