/** * Move the client to STOPPED as part of closing the current client, regardless of what state it is currently in. */ public void closeClient() { int currentValue; int newValue; do { currentValue = clientState.get(); newValue = stateWithNewStatus( currentValue, STOPPED ); } while ( !clientState.compareAndSet( currentValue, newValue ) ); }
/** * Move the client to STOPPED, unless it is already in PREPARE. */ public boolean stopClient() { int currentValue; int newValue; do { currentValue = clientState.get(); if ( isPrepare( currentValue ) ) { return false; // Can't stop clients that are in PREPARE } newValue = stateWithNewStatus( currentValue, STOPPED ); } while ( !clientState.compareAndSet( currentValue, newValue ) ); return true; }
/** * 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 ) ); }
/** * Move the client to STOPPED as part of closing the current client, regardless of what state it is currently in. */ public void closeClient() { int currentValue; int newValue; do { currentValue = clientState.get(); newValue = stateWithNewStatus( currentValue, STOPPED ); } while ( !clientState.compareAndSet( currentValue, newValue ) ); }
/** * Move the client to STOPPED, unless it is already in PREPARE. */ public boolean stopClient() { int currentValue; int newValue; do { currentValue = clientState.get(); if ( isPrepare( currentValue ) ) { return false; // Can't stop clients that are in PREPARE } newValue = stateWithNewStatus( currentValue, STOPPED ); } while ( !clientState.compareAndSet( currentValue, newValue ) ); return true; }
/** * 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 ) ); }