com.threerings.util
Class ChangeBlock

java.lang.Object
  extended by com.threerings.util.ChangeBlock

public class ChangeBlock
extends Object

A simple mechanism for preventing infinite recursion when one change listener responds to an event by making another change, which in turns notifies another (or the same) listener, which makes another change, and so on. The following example demonstrates the pattern:

 public void stateChanged (ChangeEvent event)
 {
     if (!_block.enter()) {
         return;
     }
     try {
         // do something that may cause another state change
     } finally {
         _block.leave();
     }
 }
 


Constructor Summary
ChangeBlock()
           
 
Method Summary
 boolean enter()
          Attempts to enter the change block.
 void leave()
          Leaves the change block.
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ChangeBlock

public ChangeBlock()
Method Detail

enter

public boolean enter()
Attempts to enter the change block.

Returns:
true if the change block was successfully entered, false if already in the change block.

leave

public void leave()
Leaves the change block.



Copyright © 2011. All Rights Reserved.