/** * Move the client to the PREPARE state, unless it is already STOPPED. */ public void prepare( Locks.Client client ) { int currentValue; int newValue; do { currentValue = clientState.get(); if ( isStopped( currentValue ) ) { throw new LockClientStoppedException( client ); } newValue = stateWithNewStatus( currentValue, PREPARE ); } while ( !clientState.compareAndSet( currentValue, newValue ) ); }
/** * Increment active number of clients that use current state instance. * * @param client the locks client associated with this state; used only to create pretty exception * with {@link LockClientStoppedException#LockClientStoppedException(Locks.Client)}. * @throws LockClientStoppedException when stopped. */ public void incrementActiveClients( Locks.Client client ) { int currentState; do { currentState = clientState.get(); if ( isStopped( currentState ) ) { throw new LockClientStoppedException( client ); } } while ( !clientState.compareAndSet( currentState, incrementActiveClients( currentState ) ) ); }
throw new LockClientStoppedException( this );
throw new LockClientStoppedException( this );
private void assertNotStopped() { if ( stateHolder.isStopped() ) { throw new LockClientStoppedException( this ); } }
/** * Move the client to the PREPARE state, unless it is already STOPPED. */ public void prepare( Locks.Client client ) { int currentValue; int newValue; do { currentValue = clientState.get(); if ( isStopped( currentValue ) ) { throw new LockClientStoppedException( client ); } newValue = stateWithNewStatus( currentValue, PREPARE ); } while ( !clientState.compareAndSet( currentValue, newValue ) ); }
/** * Increment active number of clients that use current state instance. * * @param client the locks client associated with this state; used only to create pretty exception * with {@link LockClientStoppedException#LockClientStoppedException(Locks.Client)}. * @throws LockClientStoppedException when stopped. */ public void incrementActiveClients( Locks.Client client ) { int currentState; do { currentState = clientState.get(); if ( isStopped( currentState ) ) { throw new LockClientStoppedException( client ); } } while ( !clientState.compareAndSet( currentState, incrementActiveClients( currentState ) ) ); }
throw new LockClientStoppedException( this );
throw new LockClientStoppedException( this );