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:
parent
a44a80e8eb
commit
cb0e4c2838
1 changed files with 22 additions and 3 deletions
|
@ -15,21 +15,40 @@ import org.eclipse.cdt.debug.mi.core.output.MIOutput;
|
||||||
*/
|
*/
|
||||||
public abstract class Command
|
public abstract class Command
|
||||||
{
|
{
|
||||||
|
private static int globalCounter;
|
||||||
|
|
||||||
int token = 0;
|
int token = 0;
|
||||||
MIOutput output;
|
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.
|
* Returns the identifier of this request.
|
||||||
*
|
*
|
||||||
* @return the identifier of this request
|
* @return the identifier of this request
|
||||||
*/
|
*/
|
||||||
public int getToken() {
|
public int getToken() {
|
||||||
|
if (token == 0) {
|
||||||
|
token = getUniqToken();
|
||||||
|
}
|
||||||
return token;
|
return token;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setToken(int token) {
|
// public void setToken(int token) {
|
||||||
this.token = token;
|
// this.token = token;
|
||||||
}
|
// }
|
||||||
|
|
||||||
public MIOutput getMIOutput() {
|
public MIOutput getMIOutput() {
|
||||||
return output;
|
return output;
|
||||||
|
|
Loading…
Add table
Reference in a new issue