diff --git a/Emulsion.Tests/Actors/SyncTaskWatcher.fs b/Emulsion.Tests/Actors/SyncTaskWatcher.fs deleted file mode 100644 index ec47f029..00000000 --- a/Emulsion.Tests/Actors/SyncTaskWatcher.fs +++ /dev/null @@ -1,50 +0,0 @@ -namespace Emulsion.Tests.Actors - -open System -open System.Threading - -open Akka.Actor -open Akka.TestKit -open Akka.TestKit.Xunit2 -open Xunit - -open Emulsion.Actors - -type TestWatcher(parent : IActorRef) = - inherit SyncTaskWatcher() - member val PreStartThreadId = 0 with get, set - member val RunInTaskThreadId = 0 with get, set - - override this.PreStart() = - base.PreStart() - this.PreStartThreadId <- Thread.CurrentThread.ManagedThreadId - - override this.RunInTask() = - this.RunInTaskThreadId <- Thread.CurrentThread.ManagedThreadId - -type ErrorTestWatcher(parent : IActorRef) = - inherit TestWatcher(parent) - override this.RunInTask() = failwith "Error" - -type SyncTaskWatcherTests() = - inherit TestKit() - - member this.createTestWatcher<'T when 'T :> ActorBase>() = - let props = Props.Create<'T>(this.TestActor) - TestActorRef<'T>(this.Sys, props) - - [] - member this.``SyncTaskWatcher should start a task in a separate thread``() = - let threadId = Thread.CurrentThread.ManagedThreadId - let watcher = this.createTestWatcher() - let actor = watcher.UnderlyingActor - this.Sys.Stop watcher - this.ExpectNoMsg() - - Assert.NotEqual(actor.PreStartThreadId, actor.RunInTaskThreadId) - - [] - member this.``SyncTaskWatcher dies when the thread throws an error``() = - let errored = this.createTestWatcher() - this.Watch errored |> ignore - this.ExpectTerminated errored |> ignore diff --git a/Emulsion.Tests/Emulsion.Tests.fsproj b/Emulsion.Tests/Emulsion.Tests.fsproj index 0137ce4b..d4c22ffb 100644 --- a/Emulsion.Tests/Emulsion.Tests.fsproj +++ b/Emulsion.Tests/Emulsion.Tests.fsproj @@ -8,7 +8,6 @@ - diff --git a/Emulsion/Actors/SyncTaskWatcher.fs b/Emulsion/Actors/SyncTaskWatcher.fs deleted file mode 100644 index 35106b1d..00000000 --- a/Emulsion/Actors/SyncTaskWatcher.fs +++ /dev/null @@ -1,25 +0,0 @@ -namespace Emulsion.Actors - -open System -open System.Threading.Tasks - -open Akka.Actor - -[] -type SyncTaskWatcher() = - inherit ReceiveActor() - - let onTaskFinished (actorType : Type) (self : IActorRef) (task : Task) : unit = - if task.Status = TaskStatus.Faulted - then - Console.Error.WriteLine("{0} error: {1}", actorType, task.Exception) - self.Tell(Akka.Actor.PoisonPill.Instance) - - abstract member RunInTask : unit -> unit - - override this.PreStart() = - let self = this.Self - Task.Factory - .StartNew(this.RunInTask, TaskCreationOptions.LongRunning) - .ContinueWith(Action(onTaskFinished (this.GetType()) self)) - |> ignore diff --git a/Emulsion/Emulsion.fsproj b/Emulsion/Emulsion.fsproj index c2d2c79b..869d326b 100644 --- a/Emulsion/Emulsion.fsproj +++ b/Emulsion/Emulsion.fsproj @@ -16,7 +16,6 @@ -