
groovyx.gpars.activeobject.InternalActor Maven / Gradle / Ivy
// GPars - Groovy Parallel Systems
//
// Copyright © 2008-11 The original author or authors
//
// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
// http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
package groovyx.gpars.activeobject;
import groovyx.gpars.MessagingRunnable;
import groovyx.gpars.actor.AbstractLoopingActor;
import groovyx.gpars.actor.Actors;
import groovyx.gpars.dataflow.DataflowVariable;
import groovyx.gpars.group.PGroup;
import org.codehaus.groovy.runtime.InvokerHelper;
import java.util.Arrays;
import java.util.Collection;
/**
* Backs active objects and invokes all object's active methods.
*
* @author Vaclav Pech
*/
@SuppressWarnings({"CallToStringEquals"})
public final class InternalActor extends AbstractLoopingActor {
private static final long serialVersionUID = 6700367864074699984L;
public static final String METHOD_NAME_PREFIX = "activeObject_";
private static final Object[] No_ARGS = new Object[0];
/**
* Just like DynamicDispatchActor, except that the actual method dispatch is static through the closure passed to the initialize() method.
*/
public InternalActor() {
initialize(new MessagingRunnable() {
@Override
protected void doRun(final Object argument) {
InternalActor.this.onMessage((Object[]) argument);
}
});
}
/**
* A DataflowVariable is passed to the actor, which will bind it once the result is known.
*
* @param args The method parameters
* @return A Promise for the real result
*/
DataflowVariable
© 2015 - 2025 Weber Informatics LLC | Privacy Policy