1
0
Fork 0
mirror of https://github.com/eclipse-cdt/cdt synced 2025-04-29 19:45:01 +02:00

getUniqToken() new method.

This commit is contained in:
Alain Magloire 2002-10-26 20:25:11 +00:00
parent a44a80e8eb
commit cb0e4c2838

View file

@ -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;