mdk_runtime.QuarkRuntimeTime Maven / Gradle / Ivy
/* Quark 1.0.452 run at 2016-11-10 18:39:58.222591 */
package mdk_runtime;
/**
* Temporary implementation based on Quark runtime, until we have native
* implementation.
*
*/
public class QuarkRuntimeTime implements Time, SchedulingActor, io.datawire.quark.runtime.QObject {
public static quark.reflect.Class mdk_runtime_QuarkRuntimeTime_ref = datawire_mdk_md.Root.mdk_runtime_QuarkRuntimeTime_md;
public mdk_runtime.actors.MessageDispatcher dispatcher;
public Boolean stopped = false;
public QuarkRuntimeTime() {}
public void onStart(mdk_runtime.actors.MessageDispatcher dispatcher) {
(this).dispatcher = dispatcher;
}
public void onStop() {
(this).stopped = true;
}
public void onMessage(mdk_runtime.actors.Actor origin, Object msg) {
if ((this).stopped) {
return;
}
Schedule sched = (Schedule) (msg);
Double seconds = (sched).seconds;
if ((seconds)==(0.0) || ((Object)(seconds) != null && ((Object) (seconds)).equals(0.0))) {
seconds = 0.1;
}
(quark.concurrent.Context.runtime()).schedule(new _ScheduleTask(this, origin, (sched).event), seconds);
}
public Double time() {
Double milliseconds = Double.valueOf((quark.concurrent.Context.runtime()).now());
return (milliseconds) / (1000.0);
}
public String _getClass() {
return "mdk_runtime.QuarkRuntimeTime";
}
public Object _getField(String name) {
if ((name)==("dispatcher") || ((Object)(name) != null && ((Object) (name)).equals("dispatcher"))) {
return (this).dispatcher;
}
if ((name)==("stopped") || ((Object)(name) != null && ((Object) (name)).equals("stopped"))) {
return (this).stopped;
}
return null;
}
public void _setField(String name, Object value) {
if ((name)==("dispatcher") || ((Object)(name) != null && ((Object) (name)).equals("dispatcher"))) {
(this).dispatcher = (mdk_runtime.actors.MessageDispatcher) (value);
}
if ((name)==("stopped") || ((Object)(name) != null && ((Object) (name)).equals("stopped"))) {
(this).stopped = (Boolean) (value);
}
}
}