Class ActorUtil


  • public final class ActorUtil
    extends java.lang.Object
    Static utility methods for working with actors.
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.lang.Object randtag()
      Generates a random identifier object (with correct equals and hashCode semantics) that is unlikely to be equal to any other object generated by this method.
      static void sendOrInterrupt​(ActorRef<?> actor, java.lang.Object message)
      Attempts to send a message to an actor, and if the message cannot be sent due to a full mailbox - interrupt the actor.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Method Detail

      • randtag

        public static java.lang.Object randtag()
        Generates a random identifier object (with correct equals and hashCode semantics) that is unlikely to be equal to any other object generated by this method. This object can be used as a good unique actor message identifier.
        Returns:
        a newly allocated random identifier object
      • sendOrInterrupt

        public static void sendOrInterrupt​(ActorRef<?> actor,
                                           java.lang.Object message)
        Attempts to send a message to an actor, and if the message cannot be sent due to a full mailbox - interrupt the actor. This is useful for sending a shutdown message to possibly malfunctioning actors.
        Parameters:
        actor - the actor to which we send the message
        message - the message