001/* For testing the workspace synchronization features. 002 003 Copyright (c) 2003-2014 The Regents of the University of California. 004 All rights reserved. 005 Permission is hereby granted, without written agreement and without 006 license or royalty fees, to use, copy, modify, and distribute this 007 software and its documentation for any purpose, provided that the above 008 copyright notice and the following two paragraphs appear in all copies 009 of this software. 010 011 IN NO EVENT SHALL THE UNIVERSITY OF CALIFORNIA BE LIABLE TO ANY PARTY 012 FOR DIRECT, INDIRECT, SPECIAL, INCIDENTAL, OR CONSEQUENTIAL DAMAGES 013 ARISING OUT OF THE USE OF THIS SOFTWARE AND ITS DOCUMENTATION, EVEN IF 014 THE UNIVERSITY OF CALIFORNIA HAS BEEN ADVISED OF THE POSSIBILITY OF 015 SUCH DAMAGE. 016 017 THE UNIVERSITY OF CALIFORNIA SPECIFICALLY DISCLAIMS ANY WARRANTIES, 018 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 019 MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE SOFTWARE 020 PROVIDED HEREUNDER IS ON AN "AS IS" BASIS, AND THE UNIVERSITY OF 021 CALIFORNIA HAS NO OBLIGATION TO PROVIDE MAINTENANCE, SUPPORT, UPDATES, 022 ENHANCEMENTS, OR MODIFICATIONS. 023 024 PT_COPYRIGHT_VERSION_2 025 COPYRIGHTENDKEY 026 027 028 */ 029package ptolemy.kernel.util.test; 030 031import java.util.LinkedList; 032import java.util.List; 033 034import ptolemy.kernel.util.Workspace; 035 036////////////////////////////////////////////////////////////////////////// 037//// TestWorkspace3 038 039/** 040 Test the following scenario: thread T1 gets read access; thread T2 gets 041 read access; T1 waits for write access; T2 releases read access; T1 wakes 042 up and gets write access. 043 044 @author Xiaojun Liu 045 @version $Id$ 046 @since Ptolemy II 3.0 047 @Pt.ProposedRating Green (eal) 048 @Pt.AcceptedRating Red (cxh) 049 050 */ 051public class TestWorkspace3 extends TestWorkspaceBase { 052 @Override 053 public void initializeTest() { 054 Workspace workspace = new Workspace(); 055 List actions = new LinkedList(); 056 AccessAction action = new AccessAction(workspace, 0, 'R', 1000, null, 057 _record, "A1"); 058 actions.add(action); 059 action = new AccessAction(workspace, 0, 'W', 1000, null, _record, "A2"); 060 actions.add(action); 061 _accessThreads.add(new AccessThread("T1", actions, this)); 062 actions = new LinkedList(); 063 action = new AccessAction(workspace, 500, 'R', 1000, null, _record, 064 "A3"); 065 actions.add(action); 066 _accessThreads.add(new AccessThread("T2", actions, this)); 067 _testTime = 6000; // ms 068 } 069}