diff options
author | Alain Magloire | 2002-10-26 20:25:11 +0000 |
---|---|---|
committer | Alain Magloire | 2002-10-26 20:25:11 +0000 |
commit | cb0e4c283857f6ed9860bc736ada033b9025ffd7 (patch) | |
tree | 0a621728b3dc9ce2cabb4c56190bfb13d5f4cb2b | |
parent | a44a80e8ebc22d9c6cc90e044620e1974a13a7e8 (diff) | |
download | org.eclipse.cdt-cb0e4c283857f6ed9860bc736ada033b9025ffd7.tar.gz org.eclipse.cdt-cb0e4c283857f6ed9860bc736ada033b9025ffd7.tar.xz org.eclipse.cdt-cb0e4c283857f6ed9860bc736ada033b9025ffd7.zip |
getUniqToken() new method.
-rw-r--r-- | debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java | 25 |
1 files changed, 22 insertions, 3 deletions
diff --git a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java index c068aeb4658..6782f2bd337 100644 --- a/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java +++ b/debug/org.eclipse.cdt.debug.mi.core/src/org/eclipse/cdt/debug/mi/core/command/Command.java @@ -15,21 +15,40 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput; */ public abstract class Command { + private static int globalCounter; + int token = 0; MIOutput output; /** + * A global counter for all command, the token + * will be use to identify uniquely a command. + * Unless the value wraps around which is unlikely. + */ + private static synchronized int getUniqToken() { + int count = ++globalCounter; + // If we ever wrap around. + if (count <= 0) { + count = globalCounter = 1; + } + return count; + } + + /** * Returns the identifier of this request. * * @return the identifier of this request */ public int getToken() { + if (token == 0) { + token = getUniqToken(); + } return token; } - public void setToken(int token) { - this.token = token; - } +// public void setToken(int token) { +// this.token = token; +// } public MIOutput getMIOutput() { return output; |