Package ptolemy.kernel.util

Examples of ptolemy.kernel.util.Workspace


@Pt.AcceptedRating Red (cxh)

*/
public class TestWorkspace4 extends TestWorkspaceBase {
    public void initializeTest() {
        Workspace workspace = new Workspace();
        List actions = new LinkedList();
        AccessAction action = new AccessAction(workspace, 0, 'W', 1000, null,
                _record, "A0");
        actions.add(action);
        _accessThreads.add(new AccessThread("T1", actions, this));
View Full Code Here


@Pt.AcceptedRating Red (cxh)

*/
public class TestWorkspace extends Thread {
    public static void main(String[] args) {
        Workspace w = new Workspace("test");
        TestWorkspace tw = new TestWorkspace("test", w);
        tw.start();
        System.out.println(tw._profile);
    }
View Full Code Here

@Pt.AcceptedRating Red (cxh)

*/
public class TestWorkspace2 extends Thread {
    public static void main(String[] args) {
        Workspace w = new Workspace("test");
        TestWorkspace2 tw = new TestWorkspace2("test", w);
        tw.start();
        System.out.println(tw.profile);
    }
View Full Code Here

        if (workspace == null) {
            // NOTE: Workspace has no name, to ensure that full names
            // of enties conform to MoML standard of starting with a
            // leading period.
            workspace = new Workspace();
        }

        _workspace = workspace;
    }
View Full Code Here

     *  TerminateProcessException.
     *
     *  @return The token contained by this receiver.
     */
    public Token get() {
        Workspace workspace = getContainer().workspace();
        Token result = null;

        // NOTE: This method used to be synchronized on this
        // receiver, but since it calls synchronized methods in
        // the director, that can cause deadlock.
        synchronized (_director) {
            while (!_terminate) {
                // Try to read.
                if (super.hasToken()) {
                    result = super.get();

                    // Need to mark any thread that is write blocked
                    // on this receiver unblocked now, before any
                    // notification, or we will detect deadlock and
                    // increase the buffer sizes.  Note that there is
                    // no need to clear the _readPending reference
                    // because that will have been cleared by the
                    // write.
                    if (_writePending != null) {
                        _director.threadUnblocked(_writePending, this);
                        _writePending = null;
                    }

                    break;
                }

                // Wait to try again.
                try {
                    _readPending = Thread.currentThread();
                    _director.threadBlocked(Thread.currentThread(), this);
                    workspace.wait(_director);
                } catch (InterruptedException e) {
                    _terminate = true;
                }
            }

View Full Code Here

                // Wait to try again.
                try {
                    _writePending = Thread.currentThread();
                    _director.threadBlocked(_writePending, this);

                    Workspace workspace = getContainer().workspace();
                    workspace.wait(_director);
                } catch (InterruptedException e) {
                    _terminate = true;
                }
            }
View Full Code Here

@Pt.AcceptedRating Red (cxh)
*/
public class Time {
    public static void main(String[] arg) throws IllegalActionException,
            NameDuplicationException {
        Workspace w = new Workspace("w");
        TypedCompositeActor toplevel = new TypedCompositeActor(w);
        toplevel.setName("toplevel");

        SDFDirector director = new SDFDirector(toplevel, "director");

View Full Code Here

     *  on the actor.
     */
    public void run() {
        _debug("-- Starting thread.");

        Workspace workspace = _director.workspace();
        boolean iterate = true;
        Throwable thrownWhenIterate = null;
        Throwable thrownWhenWrapup = null;

        try {
            // Initialize the actor.
            _actor.initialize();

            // While postfire() returns true and stop() is not called.
            while (iterate) {
                // NOTE: Possible race condition... actor.stop()
                // might be called before we get to this.
                // This will cause postfire() on the actor
                // to return false, which will stop its execution.
                if (_director.isStopFireRequested()) {
                    // And wait until the flag has been cleared.
                    _debug("-- Thread pause requested. Get lock on director.");

                    synchronized (_director) {
                        // Tell the director we're stopped (necessary
                        // for deadlock detection).
                        _director.threadHasPaused(this);

                        while (_director.isStopFireRequested()) {
                            // If a stop has been requested, in addition
                            // to a stopFire, then stop execution
                            // altogether and skip to wrapup().
                            if (_director.isStopRequested()) {
                                _debug("-- Thread stop requested, "
                                        + "so cancel iteration.");
                                break;
                            }

                            _debug("-- Thread waiting for "
                                    + "canceled pause request.");

                            try {
                                workspace.wait(_director);
                            } catch (InterruptedException ex) {
                                _debug("-- Thread interrupted, "
                                        + "so cancel iteration.");
                                break;
                            }
View Full Code Here

@Pt.AcceptedRating Red (cxh)

*/
public class TestWorkspace5 extends TestWorkspaceBase {
    public void initializeTest() {
        Workspace workspace = new Workspace();
        List actions = new LinkedList();
        AccessAction action = new AccessAction(workspace, 0, 'R', 1000, null,
                _record, "A0");
        actions.add(action);
        _accessThreads.add(new AccessThread("T1", actions, this));
View Full Code Here

                try {
                    _readPending = Thread.currentThread();
                    _director.threadBlocked(Thread.currentThread(), this,
                            PNDirector.READ_BLOCKED);

                    Workspace workspace = getContainer().workspace();
                    workspace.wait(_director);
                } catch (InterruptedException e) {
                    _terminate = true;
                }
            }
View Full Code Here

TOP

Related Classes of ptolemy.kernel.util.Workspace

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.