'Inserts object into timer.
Args:
now (int): Current time in msec
obj (object): Object to be inserted
then (int): When to return the object strictly after.'

def insert(self, now, obj, then):

    then_key = (int((then / self.bucket_size)) + 1)
    if self.entries:
        min_key = self.entries[0].end_key
        max_key = self.entries[(-1)].end_key
        if (then_key <= max_key):
            self.entries[(max(min_key, then_key) - min_key)].queue.append(obj)
            return
    next_key = (int((now / self.bucket_size)) + 1)
    if self.entries:
        last_key = self.entries[(-1)].end_key
    else:
        last_key = next_key
    then_key = max(last_key, then_key)
    self.entries.extend((_Entry(key) for key in xrange(last_key, (then_key + 1))))
    self.entries[(-1)].queue.append(obj)
