Class Server<CallMessage,​V,​CastMessage>

    • Constructor Detail

    • Method Detail

      • setDefaultTimeout

        public void setDefaultTimeout​(long timeout,
                                      java.util.concurrent.TimeUnit unit)
        Sets a default timeout for non-timed calls on this server reference. Non-timed calls that take longer than the default timeout, will throw a TimeoutException wrapped in a RuntimeException. Timed calls (those that take a timeout parameter) will not be affected.

        This method only affects calls made through this particular server actor reference and not calls to the same server actor through other references.

        This method has nothing to do with ServerActor.setTimeout

        Parameters:
        timeout - the timeout duration
        unit - the time unit of the timeout, or null to unset.
      • call

        public final V call​(CallMessage m)
                     throws java.lang.InterruptedException,
                            SuspendExecution
        Sends a synchronous request to the actor, and awaits a response. This method will wait indefinitely for the actor to respond unless a default timeout has been set for this server reference with setDefaultTimeout.

        This method may be safely called by actors and non-actor strands alike.

        Parameters:
        m - the request
        Returns:
        the value sent as a response from the actor
        Throws:
        java.lang.RuntimeException - if the actor encountered an error while processing the request
        java.lang.InterruptedException
        SuspendExecution
      • call

        public final V call​(CallMessage m,
                            long timeout,
                            java.util.concurrent.TimeUnit unit)
                     throws java.util.concurrent.TimeoutException,
                            java.lang.InterruptedException,
                            SuspendExecution
        Sends a synchronous request to the actor, and awaits a response, but no longer than the given timeout.

        This method may be safely called by actors and non-actor strands alike.

        Parameters:
        m - the request
        timeout - the maximum duration to wait for a response.
        unit - the time unit of the timeout
        Returns:
        the value sent as a response from the actor
        Throws:
        java.lang.RuntimeException - if the actor encountered an error while processing the request
        java.util.concurrent.TimeoutException - if the timeout expires before a response has been received.
        java.lang.InterruptedException
        SuspendExecution
      • call

        public final V call​(CallMessage m,
                            Timeout timeout)
                     throws java.util.concurrent.TimeoutException,
                            java.lang.InterruptedException,
                            SuspendExecution
        Sends a synchronous request to the actor, and awaits a response, but no longer than the given timeout.

        This method may be safely called by actors and non-actor strands alike.

        Parameters:
        m - the request
        timeout - the method will not block for longer than the amount remaining in the Timeout
        Returns:
        the value sent as a response from the actor
        Throws:
        java.lang.RuntimeException - if the actor encountered an error while processing the request
        java.util.concurrent.TimeoutException - if the timeout expires before a response has been received.
        java.lang.InterruptedException
        SuspendExecution
      • cast

        public final void cast​(CastMessage m)
                        throws SuspendExecution
        Sends an asynchronous request to the actor and returns immediately (may block until there's room available in the actor's mailbox).
        Parameters:
        m - the request
        Throws:
        SuspendExecution
      • toString

        public java.lang.String toString()
        Overrides:
        toString in class ActorRef<java.lang.Object>