def reschedule(event)
            # Check promise is not resolved
            return if event.resolved?

            @critical.synchronize {
                # Remove the event from the scheduled list and ensure it is in the schedules set
                if @schedules.include?(event)
                    remove(event)
                else
                    @schedules << event
                end

                # optimal algorithm for inserting into an already sorted list
                Bisect.insort(@scheduled, event)

                # Update the timer
                check_timer
            }
        end
def reschedule(event)
            # Check promise is not resolved
            return if event.resolved?

            @critical.synchronize {
                # Remove the event from the scheduled list and ensure it is in the schedules set
                if @schedules.include?(event)
                    remove(event)
                else
                    @schedules << event
                end

                # optimal algorithm for inserting into an already sorted list
                Bisect.insort(@scheduled, event)

                # Update the timer
                check_timer
            }
        end
Schedules an event for execution

 @param event [ScheduledEvent]