@Override
    public CallEvent drain() {
        CallEvent callEvent = delayedEvents.drain();
        if (callEvent == null) {
            validate();
            return null;
        }

        // double check this is an end event
        assert(callEvent.startTS == null);
        assert(callEvent.endTS != null);

        // return the agent/phone for this event to the available lists
        agentsAvailable.add(callEvent.agentId);
        phoneNumbersAvailable.add(callEvent.phoneNo);

        validate();
        return callEvent;
    }
@ Override public CallEvent drain ( ) { CallEvent callEvent = delayedEvents . drain ( ) ; if ( callEvent == null ) { validate ( ) ; return null ; } assert ( callEvent . startTS == null ) ; assert ( callEvent . endTS != null ) ; agentsAvailable . add ( callEvent . agentId ) ; phoneNumbersAvailable . add ( callEvent . phoneNo ) ; validate ( ) ; return callEvent ; }
Ignore any scheduled delays and return events in
schedule order until empty.