From 896134e4f29096273d45715d1b2f097876ab1a20 Mon Sep 17 00:00:00 2001 From: Silv3rcircl3 Date: Mon, 18 Jan 2016 17:02:10 +0100 Subject: [PATCH] Implemented StarTime and Uptime --- .../CoreAPISpec.ApproveCore.approved.txt | 2 ++ src/core/Akka/Actor/ActorSystem.cs | 11 +++++++++++ 2 files changed, 13 insertions(+) diff --git a/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt b/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt index 26030a47e32..d3c0b2244ce 100644 --- a/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt +++ b/src/core/Akka.API.Tests/CoreAPISpec.ApproveCore.approved.txt @@ -315,8 +315,10 @@ namespace Akka.Actor public abstract Akka.Actor.IScheduler Scheduler { get; } public abstract Akka.Serialization.Serialization Serialization { get; } public abstract Akka.Actor.Settings Settings { get; } + public System.TimeSpan StartTime { get; } [System.ObsoleteAttribute("Use WhenTerminated instead. This property will be removed in future versions")] public abstract System.Threading.Tasks.Task TerminationTask { get; } + public System.TimeSpan Uptime { get; } public abstract System.Threading.Tasks.Task WhenTerminated { get; } public abstract Akka.Actor.IActorRef ActorOf(Akka.Actor.Props props, string name = null); public abstract Akka.Actor.ActorSelection ActorSelection(Akka.Actor.ActorPath actorPath); diff --git a/src/core/Akka/Actor/ActorSystem.cs b/src/core/Akka/Actor/ActorSystem.cs index 219165a5f89..75be1d5e492 100644 --- a/src/core/Akka/Actor/ActorSystem.cs +++ b/src/core/Akka/Actor/ActorSystem.cs @@ -12,6 +12,7 @@ using Akka.Configuration; using Akka.Dispatch; using Akka.Event; +using Akka.Util; namespace Akka.Actor { @@ -73,6 +74,16 @@ public abstract class ActorSystem : IActorRefFactory, IDisposable /// Gets the log public abstract ILoggingAdapter Log { get; } + /// + /// Start-up time since the epoch. + /// + public TimeSpan StartTime { get; } = DateTime.UtcNow - new DateTime(1970, 1, 1, 0, 0, 0, DateTimeKind.Utc); + + /// + /// Up-time of this actor system. + /// + public TimeSpan Uptime => MonotonicClock.ElapsedHighRes; + /// /// Creates a new ActorSystem with the specified name, and the specified Config ///