Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
  • 21:12
    Aaronontheweb commented #4001
  • 21:11

    Aaronontheweb on dev

    Added missing Persistence Testiā€¦ (compare)

  • 21:11
    Aaronontheweb closed #4001
  • 20:59
    sean-gilliam commented #3889
  • 20:59
    sean-gilliam opened #4001
  • 16:07
    spankr commented #3921
  • 15:55
    Aaronontheweb labeled #3765
  • 15:54
    Aaronontheweb labeled #3765
  • 15:54
    Aaronontheweb milestoned #3765
  • 15:53
    Aaronontheweb closed #3902
  • 15:23
    Aaronontheweb commented #3921
  • 15:11
    spankr commented #3921
  • 15:05
    Aaronontheweb commented #3973
  • 15:05
    Aaronontheweb commented #3973
  • 15:02
    Aaronontheweb commented #4000
  • 15:02
    Aaronontheweb milestoned #4000
  • 15:02
    Aaronontheweb assigned #4000
  • 15:01
    Aaronontheweb commented #3889
  • 14:55
    sean-gilliam commented #3889
  • 14:35
    IgorFedchenko commented #3973
nathvi
@nathvi
Is this bad design?
public void RunActorSytem()
        {
            try
            {
                var actorSystem = ActorSystem.Create("ActorSystem");
                var playerActor1 = actorSystem.ActorOf(Props.Create(() => new PlayerActor("Bob")));
                var playerActor2 = actorSystem.ActorOf(Props.Create(() => new PlayerActor("Susan")));
                var playerActor3 = actorSystem.ActorOf(Props.Create(() => new PlayerActor("Simon")));

                // All events get persisted to EventJournal Sql Server tbl.
                // When process is restarted, EventJournal replays messages to actors to restore state,
                // BEFORE messages from mailboxes can be processed.
                Task.Run(() => RunHitHealLoop(playerActor1));
                Task.Run(() => RunHitHealLoop(playerActor2));
                Task.Run(() => RunHitHealLoop(playerActor3));
            }
            catch (Exception e)
            {
                Log.Error(e.Message);
                throw e;
            }
        }
void RunHitHealLoop(IActorRef playerActor)
        {
            while (true)
            {
                playerActor.Tell(new HitMessage(3));
                playerActor.Tell(new AddHealthMessage(10));
                playerActor.Tell(new DisplayStatusMessage());
                Thread.Sleep(3000);
            }
        }
Arjen Smits
@Danthar
Besides that i would do a await Task.Delay instead of Thread.Sleep. There is not a whole lot to go on here.
What is your goal here ?
nathvi
@nathvi
To spawn some threads that send messages to actors in a cycle.
Arjen Smits
@Danthar
I get that :) But your question implies that you have some doubts concerning this particular example. Or perhaps some specific questions ?
nathvi
@nathvi
Just curious if it makes sense to do it that way.
No particular thing.
Arjen Smits
@Danthar
If it works for you. Sure. I wouldn't do it like this when inside another actor.
and when you start building out. You are probably going to want some kind of actor that manages PlayerActors
nathvi
@nathvi
A "PlayerManagerActor"
or a "PlayerGodActor"
Arjen Smits
@Danthar
depends on what problem your solving
usually your system has more then just players
so there comes a point where you will want to fetch an IActorRef to a certain playerActor
Thats where something like the PlayerManagerActor comes into play
nathvi
@nathvi
hence the PlayerGodActor
Arjen Smits
@Danthar
it would be a well known toplevel actor in your hierarchy
which the rest of your system uses to retrieve specific playeractors
and do stuff with it :)
nathvi
@nathvi
Manager sounds like something human. Only gods can create people instantly.
Arjen Smits
@Danthar
Naming things is one of the hardest things in our field ;)
and often subjective
nathvi
@nathvi
true
GodOfPlayersActor?
Arjen Smits
@Danthar
I wouldn't name it PlayerGodActor for instance. Because i would think its somekind of special PlayerActor
And it would not instantly convey "im the actor responsible for managing playeractors"
PlayerRegistryActor is also an option
nathvi
@nathvi
That's so boring though
lol
Arjen Smits
@Danthar
hahaha true
nathvi
@nathvi
PlayerMasterActor
LordOfPlayerActors
Arjen Smits
@Danthar
^^
PlayerUniverse
nathvi
@nathvi
I would think the actor system itself would be the player universe
GrandWizardOfPlayerActors
Manager is too weak in my opinion. Managers manage existing people. They don't create them instantly or make them vanish.
Arjen Smits
@Danthar
It can do whatever you want it to do :)
gl though ;) gtg
nathvi
@nathvi
aiight
me-slove
@me-slove
Like PlayerController or PlayerManager
naming over time is a critical aspect as you said @Danthar
Rodger Brennan
@rodgerbrennan
Can actors be reparented?
nathvi
@nathvi
Good question.
nathvi
@nathvi
I think it makes more sense to call the child actors slave actors.
Arjen Smits
@Danthar
@rodgerbrennan no. If you want to change the Parent, as in Context.Parent of an actor. It has to be recreated under that parent. Also. It means that the actorpath will change.
@nathvi we like child actors better ;). Since the Parent actor can decide about its lifecycle. (supervisionstrategy and sofort). And ofcourse also because thats what the JVM Akka calls it. Because its terminology integral to the design of Akka, we follow that same terminology
Sam13
@Sam13
Everybody used FileIO.FromFile for the same file at the same time?
I always get an IOException 'The process cannot access the file xyz because is being used by another process' the second time. I'm using Akka 1.3.7.
Callstack:
mscorlib.dll!System.IO.__Error.WinIOError(int errorCode, string maybeFullPath) Unknown mscorlib.dll!System.IO.FileStream.Init(string path, System.IO.FileMode mode, System.IO.FileAccess access, int rights, bool useRights, System.IO.FileShare share, int bufferSize, System.IO.FileOptions options, Microsoft.Win32.Win32Native.SECURITY_ATTRIBUTES secAttrs, string msgPath, bool bFromProxy, bool useLongPath, bool checkHost) Unknown mscorlib.dll!System.IO.FileStream.FileStream(string path, System.IO.FileMode mode, System.IO.FileAccess access, System.IO.FileShare share) Unknown mscorlib.dll!System.IO.FileInfo.Open(System.IO.FileMode mode, System.IO.FileAccess access) Unknown Akka.Streams.dll!Akka.Streams.Implementation.IO.FilePublisher.PreStart() Unknown Akka.Streams.dll!Akka.Streams.Actors.ActorPublisher<Akka.IO.ByteString>.AroundPreStart() Unknown Akka.dll!Akka.Actor.ActorCell.UseThreadContext(System.Action action) Unknown Akka.dll!Akka.Actor.ActorCell.Create(System.Exception failure) Unknown Akka.dll!Akka.Actor.ActorCell.SysMsgInvokeAll(Akka.Dispatch.SysMsg.EarliestFirstSystemMessageList messages, int currentState) Unknown Akka.dll!Akka.Dispatch.Mailbox.ProcessAllSystemMessages() Unknown Akka.dll!Akka.Dispatch.Mailbox.Run.AnonymousMethod__36_0() Unknown Akka.dll!Akka.Actor.ActorCell.UseThreadContext(System.Action action) Unknown Akka.dll!Akka.Dispatch.Mailbox.Run() Unknown mscorlib.dll!System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem() Unknown mscorlib.dll!System.Threading.ThreadPoolWorkQueue.Dispatch() Unknown