Skip to main content
aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAlain Magloire2002-10-26 20:25:11 +0000
committerAlain Magloire2002-10-26 20:25:11 +0000
commitcb0e4c283857f6ed9860bc736ada033b9025ffd7 (patch)
tree0a621728b3dc9ce2cabb4c56190bfb13d5f4cb2b
parenta44a80e8ebc22d9c6cc90e044620e1974a13a7e8 (diff)
downloadorg.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.java25
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;

Back to the top