From 8a5f724ab5f89f6cc4e6d6f3db3b310852093ec3 Mon Sep 17 00:00:00 2001 From: Brian Frank Date: Fri, 6 Sep 2024 08:44:14 -0400 Subject: [PATCH] concurrent: ActorMsg allow id to be any Obj so that it can be used with enums too --- src/concurrent/fan/ActorMsg.fan | 16 ++++++++-------- src/concurrent/test/ActorTest.fan | 4 ++++ 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/src/concurrent/fan/ActorMsg.fan b/src/concurrent/fan/ActorMsg.fan index 64802f958..0f20cd266 100644 --- a/src/concurrent/fan/ActorMsg.fan +++ b/src/concurrent/fan/ActorMsg.fan @@ -13,20 +13,20 @@ const class ActorMsg { ** Constructor with zero arguments - new make0(Str id) + new make0(Obj id) { this.id = id } ** Constructor with one argument - new make1(Str id, Obj? a) + new make1(Obj id, Obj? a) { this.id = id this.a = a } ** Constructor with two arguments - new make2(Str id, Obj? a, Obj? b) + new make2(Obj id, Obj? a, Obj? b) { this.id = id this.a = a @@ -34,7 +34,7 @@ const class ActorMsg } ** Constructor with three arguments - new make3(Str id, Obj? a, Obj? b, Obj? c) + new make3(Obj id, Obj? a, Obj? b, Obj? c) { this.id = id this.a = a @@ -43,7 +43,7 @@ const class ActorMsg } ** Constructor with four arguments - new make4(Str id, Obj? a, Obj? b, Obj? c, Obj? d) + new make4(Obj id, Obj? a, Obj? b, Obj? c, Obj? d) { this.id = id this.a = a @@ -53,7 +53,7 @@ const class ActorMsg } ** Constructor with five arguments - new make5(Str id, Obj? a, Obj? b, Obj? c, Obj? d, Obj? e) + new make5(Obj id, Obj? a, Obj? b, Obj? c, Obj? d, Obj? e) { this.id = id this.a = a @@ -63,8 +63,8 @@ const class ActorMsg this.e = e } - ** Message identifier key - const Str id + ** Message identifier key, typically string or enum + const Obj id ** Argument a const Obj? a diff --git a/src/concurrent/test/ActorTest.fan b/src/concurrent/test/ActorTest.fan index db46c38de..303327cbe 100644 --- a/src/concurrent/test/ActorTest.fan +++ b/src/concurrent/test/ActorTest.fan @@ -938,6 +938,10 @@ class ActorTest : Test verifyMsg(ActorMsg("foo", "a", "b", "c", "d"), 4, "a", "b", "c", "d", null) verifyMsg(ActorMsg("foo", "a", "b", "c", "d", "e"), 5, "a", "b", "c", "d", "e") verifyMsg(ActorMsg("foo", "a", "b", null, "d", "e"), 5, "a", "b", null, "d", "e") + + m := ActorMsg(123, "alpha") + verifyEq(m.id, 123) + verifyEq(m.a, "alpha") } Void verifyMsg(ActorMsg m, Int count, Obj? a, Obj? b, Obj? c, Obj? d, Obj? e)