Exemplo n.º 1
0
 public void revertRestartRequired(Object stamp) {
   // If 'state' still has the state we last set in restartRequired(), change to RUNNING
   Integer theirStamp = Integer.class.cast(stamp);
   synchronized (service) {
     if (state.compareAndSet(
         State.RESTART_REQUIRED, State.RUNNING, theirStamp, this.stamp.incrementAndGet())) {
       service.stateChanged(State.RUNNING);
     }
   }
 }
Exemplo n.º 2
0
 public Object setRestartRequired() {
   AtomicStampedReference<State> stateRef = state;
   int newStamp = stamp.incrementAndGet();
   int[] receiver = new int[1];
   // Keep trying until stateRef is RESTART_REQUIRED with our stamp
   for (; ; ) {
     State was = stateRef.get(receiver);
     if (was == State.STARTING || was == State.STOPPING) {
       break;
     }
     synchronized (service) {
       if (stateRef.compareAndSet(was, State.RESTART_REQUIRED, receiver[0], newStamp)) {
         service.stateChanged(State.RESTART_REQUIRED);
         break;
       }
     }
   }
   return Integer.valueOf(newStamp);
 };
Exemplo n.º 3
0
 public void setStarting() {
   synchronized (service) {
     state.set(State.STARTING, stamp.incrementAndGet());
     service.stateChanged(State.STARTING);
   }
 }
Exemplo n.º 4
0
 public void setRunning() {
   synchronized (service) {
     state.set(State.RUNNING, stamp.incrementAndGet());
     service.stateChanged(State.RUNNING);
   }
 }