Commits

Boris FELD  committed 1e81b92 Merge
  • Participants
  • Parent commits c08691c, dc77db8

Comments (0)

Files changed (2)

File janus/janus-kernel/kernel/src/main/java/org/janusproject/kernel/agent/Agent.java

 
 import org.janusproject.kernel.address.Address;
 import org.janusproject.kernel.address.AgentAddress;
+import org.janusproject.kernel.agentsignal.BufferedSignalManager;
+import org.janusproject.kernel.agentsignal.SignalManager;
 import org.janusproject.kernel.condition.AfterTimeCondition;
 import org.janusproject.kernel.condition.TimeCondition;
 import org.janusproject.kernel.configuration.JanusProperty;
 		if(this.mailbox instanceof BufferedMailbox) {
 			((BufferedMailbox)this.mailbox).synchronizeMessages();
 		}
+		
+		SignalManager sm = getSignalManager();
+		if (sm instanceof BufferedSignalManager) {
+			((BufferedSignalManager)sm).sync();
+		}
 
 		if (isSelfKillableNow()) {
 			return killMe();

File janus/janus-kernel/timemanager/src/main/java/org/janusproject/kernel/time/VMKernelTimeManager.java

 import java.util.concurrent.TimeUnit;
 
 /**
- * This class retreives time from the virtual machine.
+ * This class retreives time according to how the time
+ * on the virtual machine evolves.
+ * The time in the time manager is initialized with {@code 0}.
+ * And the time evolves at the same rate as the current
+ * operating system clock. 
  * 
  * @author $Author: sgalland$
  * @version $FullVersion$
  */
 public class VMKernelTimeManager implements KernelTimeManager {
 
+	private final long initialTime;
+	
+	/**
+	 */
+	public VMKernelTimeManager() {
+		this.initialTime = System.nanoTime();
+	}
+	
 	/** {@inheritDoc}
 	 */
 	@Override
 		return new Date(System.currentTimeMillis());
 	}
 
+	private double getCurrentTimeAsMillis() {
+		return (System.nanoTime() - this.initialTime) * 1e-6;
+	}
+	
 	/** {@inheritDoc}
 	 */
 	@Override
 	public float getCurrentTime() {
-		return System.currentTimeMillis();
+		return (float) getCurrentTimeAsMillis();
 	}
 
 	/** {@inheritDoc}
 	@Override
 	public float getCurrentTime(TimeUnit unit) {
 		assert(unit!=null);
-		return unit.convert(System.currentTimeMillis(), TimeUnit.MILLISECONDS);
+		return unit.convert((long)getCurrentTimeAsMillis(), TimeUnit.MILLISECONDS);
 	}
 
 }