Bug 302305 - Added a timeout to queries which are run more frequently.

Change-Id: I3d3cf27c6f7fda7171633b9e70d26c4d3a89e2dd
Signed-off-by: Mario Pierro <mario.pierro@iar.com>
This commit is contained in:
Mario Pierro 2016-03-09 02:20:28 +01:00 committed by Gerrit Code Review @ Eclipse.org
parent 6a61206d08
commit adbed0ba76
4 changed files with 45 additions and 6 deletions

View file

@ -0,0 +1,27 @@
/*******************************************************************************
* Copyright (c) 2016 IAR Systems AB
* All rights reserved. This program and the accompanying materials
* are made available under the terms of the Eclipse Public License v1.0
* which accompanies this distribution, and is available at
* http://www.eclipse.org/legal/epl-v10.html
*
* Contributors:
* IAR Systems - initial API and implementation
*******************************************************************************/
package org.eclipse.cdt.dsf.debug.internal.ui.actions;
/**
* Constants used by the DSF UI action adapters
*
* @noimplement This interface is not intended to be implemented by clients.
*/
interface IDsfActionsConstants {
/**
* The timeout in ms which action adapters will wait before disabling
* the action itself, in order to avoid blocking the UI thread while
* waiting for the DSF thread to service a blocking query.
*/
static final int ACTION_ADAPTERS_TIMEOUT_MS = 500;
}

View file

@ -12,6 +12,8 @@ package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.model.IMoveToAddress;
@ -63,10 +65,11 @@ public class MoveToLine implements IMoveToLine, IMoveToAddress {
}
};
session.getExecutor().execute(query);
return query.get();
return query.get(IDsfActionsConstants.ACTION_ADAPTERS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (TimeoutException e) {
}
}
return false;
@ -134,10 +137,11 @@ public class MoveToLine implements IMoveToLine, IMoveToAddress {
}
};
session.getExecutor().execute(query);
return query.get();
return query.get(IDsfActionsConstants.ACTION_ADAPTERS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (TimeoutException e) {
}
}
return false;

View file

@ -12,6 +12,8 @@ package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.model.IResumeAtAddress;
@ -69,10 +71,11 @@ public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress {
}
};
session.getExecutor().execute(query);
return query.get();
return query.get(IDsfActionsConstants.ACTION_ADAPTERS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (TimeoutException e) {
}
}
return false;
@ -145,10 +148,11 @@ public class ResumeAtLine implements IResumeAtLine, IResumeAtAddress {
}
};
session.getExecutor().execute(query);
return query.get();
return query.get(IDsfActionsConstants.ACTION_ADAPTERS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (TimeoutException e) {
}
}
return false;

View file

@ -13,6 +13,8 @@ package org.eclipse.cdt.dsf.debug.internal.ui.actions;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.RejectedExecutionException;
import java.util.concurrent.TimeUnit;
import java.util.concurrent.TimeoutException;
import org.eclipse.cdt.core.IAddress;
import org.eclipse.cdt.debug.core.model.IRunToAddress;
@ -72,10 +74,11 @@ public class RunToLine implements IRunToLine, IRunToAddress {
}
};
session.getExecutor().execute(query);
return query.get();
return query.get(IDsfActionsConstants.ACTION_ADAPTERS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (TimeoutException e) {
}
}
return false;
@ -148,10 +151,11 @@ public class RunToLine implements IRunToLine, IRunToAddress {
}
};
session.getExecutor().execute(query);
return query.get();
return query.get(IDsfActionsConstants.ACTION_ADAPTERS_TIMEOUT_MS, TimeUnit.MILLISECONDS);
} catch (RejectedExecutionException e) {
} catch (InterruptedException e) {
} catch (ExecutionException e) {
} catch (TimeoutException e) {
}
}
return false;