/** * @return wether this is a proxy to a remotely running actor */ @CallerSideMethod public boolean isRemote() { return __remoteId != 0; }
/** * @return the scheduler associated with this actor (determines scheduling of processing of actors to threads) */ @CallerSideMethod public Scheduler getScheduler() { return __scheduler; }
/** * dispatch call to a service. (use forwardXX to send) * @param rce * @param clientRemoteRegistry * @return return false in case call could not be dispatched */ @CallerSideMethod protected abstract boolean dispatchRemoteCall(RemoteCallEntry rce, ConnectionRegistry clientRemoteRegistry );
/** * synchronous method returning true in case this actor is stopped */ @CallerSideMethod public boolean isStopped() { return __stopped; }
/** * @return the scheduler associated with this actor (determines scheduling of processing of actors to threads) */ @CallerSideMethod public Scheduler getScheduler() { return __scheduler; }
/** * WARNING: call rarely, this method might have O(n) runtime with default unbounded queues. * @return true if mailbox fill size is ~half capacity */ @CallerSideMethod public boolean isMailboxPressured() { return __mailbox.size() * 2 > __mbCapacity; }
/** * WARNING: call rarely, this method might have O(n) runtime with default unbounded queues. * @return an estimation on the queued up callback entries. Can be used for bogus flow control. */ @CallerSideMethod public int getCallbackSize() { return __cbQueue.size(); }
@CallerSideMethod public void __removeRemoteConnection( ConnectionRegistry con ) { if ( __connections != null ) { __connections.remove(con); } } @CallerSideMethod public void __stop() { __stopImpl(); }
/** * @return wether this is the "real" implementation or the proxy object */ @CallerSideMethod public boolean isProxy() { return getActor() != this; }
/** * @return wether this is the "real" implementation or the proxy object */ @CallerSideMethod public boolean isProxy() { return getActor() != this; }
@CallerSideMethod protected Actor getRemoteRef() { List<Actor> remoteServices = getActor().remoteServices; if ( remoteServices.size() == 0 ) return null; return remoteServices.get(0); }
/** * @return true wether this actor is published to network */ @CallerSideMethod public boolean isPublished() { return __connections != null && __connections.peek() != null; }
@CallerSideMethod public Object __enqueueCall( Actor receiver, String methodName, Object args[], boolean isCB ) { if ( __stopped ) { if ( methodName.equals("stop") ) // ignore double stop return null; __addDeadLetter(receiver, methodName); // throw new RuntimeException("Actor " + this + " received message after being stopped " + methodName); } return __scheduler.enqueueCall(sender.get(), receiver, methodName, args, isCB); }
@CallerSideMethod protected void setRemoteRef(Actor remoteRef) { ArrayList services = new ArrayList(); services.add(remoteRef); services.addAll(getActor().remoteServices); getActor().remoteServices = services; Log.Info(this,"service added. #services "+services.size()); }
@Override @CallerSideMethod protected boolean dispatchRemoteCall(RemoteCallEntry rce, ConnectionRegistry clientRemoteRegistry) { if ( getActor().remoteServices.size() == 0 ) return false; // attention: breaking threading contract here ! (see immutable add in register) boolean[] done = {false}; Callback[] selected = {null}; dispatchImpl(rce, clientRemoteRegistry, done, selected); return true; }
@CallerSideMethod protected void setRemoteRef(Actor remoteRef) { getActor().remRef = remoteRef; self().remRef = remoteRef; }
@CallerSideMethod public void __addStopHandler( Callback<SELF> cb ) { if ( __stopHandlers == null ) { getActorRef().__stopHandlers = new ConcurrentLinkedQueue(); getActor().__stopHandlers = getActorRef().__stopHandlers; } __stopHandlers.add(cb); }
@Override @CallerSideMethod protected void willDispatch() { getActor().count++; if ( getActor().count >= getActor().remoteServices.size() ) getActor().count = 0; }
/** * just enqueue given runable to this actors mailbox and execute on the actor's thread * WARNING: the similar named method execInThreadPool() works different (bad naming) * @param command */ @CallerSideMethod @Local @Override public void execute(Runnable command) { self().__submit(command); }
/** * avoids exception when closing an actor after stop has been called. */ @CallerSideMethod public void stopSafeClose() { if ( isStopped() ) { getActor().close(); // is threadsafe } else { self().close(); } }