public Result unregisterReference ( SharedStateRegistryKey registrationKey ) { Preconditions . checkNotNull ( registrationKey ) ; final Result result ; final StreamStateHandle scheduledStateDeletion ; SharedStateRegistry . SharedStateEntry entry ; synchronized ( registeredStates ) { entry = registeredStates . get ( registrationKey ) ; Preconditions . checkState ( entry != null , "Cannot unregister a state that is not registered." ) ; entry . decreaseReferenceCount ( ) ; // Remove the state from the registry when it's not referenced any more. if ( entry . getReferenceCount ( ) <= 0 ) { registeredStates . remove ( registrationKey ) ; scheduledStateDeletion = entry . getStateHandle ( ) ; result = new Result ( null , 0 ) ; } else { scheduledStateDeletion = null ; result = new Result ( entry ) ; } } LOG . trace ( "Unregistered shared state {} under key {}." , entry , registrationKey ) ; scheduleAsyncDelete ( scheduledStateDeletion ) ; return result ; }
Releases one reference to the given shared state in the registry . This decreases the reference count by one . Once the count reaches zero the shared state is deleted .