class DelayedApplyMixin:
	def __init__(self):
		self.doables = []
	
	def QueueLater(self, frames, function, *args, **kwargs):
		"""
		Queue a function up to be run later on.
		"""
		self.doables.append([function, frames, args, kwargs])
	
	def Queue(self, function, *args, **kwargs):
		"""
		Add a function to be run in the next iteration.
		"""
		self.QueueLater(0, function, *args, **kwargs)
	
	def DoAll(self):
		"""
		Delete and run functions as neccesary.
		"""
		[self.doables.remove(d) for d in [f for f in self.doables if self.RunAndFindDeletables(f)]]
	
	def RunAndFindDeletables(self, f):
		if f[1] == 0:
			f[0](*f[2], **f[3])
		f[1] -= 1
		return f[1] < 0


