package at.oefai.aaa.agent;

import java.util.concurrent.CountDownLatch;
import at.oefai.aaa.thread.IPausable;
import at.oefai.aaa.thread.StoppableThread;

/**
 * Wrapper for the actor-agents that is pausable.
 * @author Stefan Rank
 */
public class SchundActor implements IPausable {
    private final StoppableThread stoppable;
    private final String myName;

    public SchundActor(final String name, final ActorInterpreter si) {
        assert name != null : "non-null name required";
        assert ! name.equals("") : "non-empty name required";
        this.myName = name;
        this.stoppable = new StoppableThread(si);
        si.assertName();
    }

    public final String getName() {
        return this.myName;
    }

    public final void start(final CountDownLatch startSignal) {
        this.stoppable.start(startSignal);
    }
    public final void pause(final CountDownLatch returnSignal) {
        this.stoppable.stop(returnSignal);
    }
    public final boolean isPaused() {
        return this.stoppable.isStopped();
    }

}
