blob: b46d6f339d90521ec89bf65fba5e199200ebfd58 [file] [log] [blame]
/**********************************************************************
* Copyright (c) 2004 IBM Corporation and others. All rights reserved. This
* program and the accompanying materials are made available under the terms of
* the Common Public License v1.0 which accompanies this distribution, and is
* available at http://www.eclipse.org/legal/cpl-v10.html
*
* Contributors:
* IBM - Initial API and implementation
**********************************************************************/
package org.eclipse.core.tests.runtime.jobs;
import org.eclipse.core.internal.jobs.JobManager;
import org.eclipse.core.runtime.IProgressMonitor;
import org.eclipse.core.runtime.OperationCanceledException;
import org.eclipse.core.runtime.jobs.*;
import org.eclipse.core.tests.harness.TestBarrier;
/**
*
*/
/**
* This runnable will try to begin the given rule in the Job Manager. It will
* end the rule before returning.
*/
class SimpleRuleRunner implements Runnable {
private ISchedulingRule rule;
private IProgressMonitor monitor;
private int[] status;
RuntimeException exception;
private static final IJobManager manager = JobManager.getInstance();
public SimpleRuleRunner(ISchedulingRule rule, int[] status, IProgressMonitor monitor) {
this.rule = rule;
this.monitor = monitor;
this.status = status;
this.exception = null;
}
public void run() {
//tell the caller that we have entered the run method
status[0] = TestBarrier.STATUS_RUNNING;
try {
try {
manager.beginRule(rule, monitor);
} finally {
manager.endRule(rule);
}
} catch (OperationCanceledException e) {
//ignore
} catch (RuntimeException e) {
exception = e;
} finally {
status[0] = TestBarrier.STATUS_DONE;
}
}
}