com.threerings.util
Class ChangeBlock
java.lang.Object
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();
}
}
|
Method Summary |
boolean |
enter()
Attempts to enter the change block. |
void |
leave()
Leaves the change block. |
ChangeBlock
public ChangeBlock()
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.