X-Git-Url: https://gerrit.simantics.org/r/gitweb?p=simantics%2Fplatform.git;a=blobdiff_plain;f=bundles%2Forg.simantics.simulator.variable%2Fsrc%2Forg%2Fsimantics%2Fsimulator%2Fvariable%2FRealm.java;fp=bundles%2Forg.simantics.simulator.variable%2Fsrc%2Forg%2Fsimantics%2Fsimulator%2Fvariable%2FRealm.java;h=b3ecdeec3a11b2d6213fbbb21ddc50e854cbb060;hp=0000000000000000000000000000000000000000;hb=969bd23cab98a79ca9101af33334000879fb60c5;hpb=866dba5cd5a3929bbeae85991796acb212338a08 diff --git a/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/Realm.java b/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/Realm.java new file mode 100644 index 000000000..b3ecdeec3 --- /dev/null +++ b/bundles/org.simantics.simulator.variable/src/org/simantics/simulator/variable/Realm.java @@ -0,0 +1,41 @@ +/******************************************************************************* + * Copyright (c) 2013 Association for Decentralized Information Management + * in Industry THTH ry. + * 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: + * VTT Technical Research Centre of Finland - initial API and implementation + * Semantum Oy - initial API and implementation + *******************************************************************************/ +package org.simantics.simulator.variable; + +/** + * Realm controls access to some local resource. + * + * @author Hannu Niemistö + * @author Antti Villberg + */ +public interface Realm { + + /** + * Executes the given runnable in this realm synchronously so that the method + * returns only after the runnable has finished. Can be called only when not + * inside the realm. Calling the method in the realm either causes + * a deadlock or {@link IllegalStateException}. + * @throws InterruptedException + */ + void syncExec(Runnable runnable) throws InterruptedException; + + /** + * Executes the runnable in this realm asynchronously. + * This method can be called freely inside or outside of the realm. + * When executed inside the realm it is guaranteed that no + * internal event (for example a simulator step) is taken before + * executing the runnable. + */ + void asyncExec(Runnable runnable); + +}