public boolean returnReservedValues ( ) throws FetchException , PersistException { synchronized ( mStoredSequence ) { if ( mHasReservedValues ) { Transaction txn = mRepository . enterTopTransaction ( null ) ; txn . setForUpdate ( true ) ; try { // Compare known StoredSequence with current persistent // one. If same, then reserved values can be returned. StoredSequence current = mStorage . prepare ( ) ; current . setName ( mStoredSequence . getName ( ) ) ; if ( current . tryLoad ( ) && current . equals ( mStoredSequence ) ) { mStoredSequence . setNextValue ( mNextValue + mIncrement ) ; mStoredSequence . update ( ) ; txn . commit ( ) ; mHasReservedValues = false ; return true ; } } finally { txn . exit ( ) ; } } } return false ; }
Allow any unused reserved values to be returned for re - use . If the repository is shared by other processes then reserved values might not be returnable .