/* ==================================================================== */ /* SEQ_PERSIST.C */ /* */ /* -------------------------------------------------------------------- */ /*************************************************************************** * * Copyright (c) 1989, 1990, 1991, 1992, 1993 * Rector and Visitors of the University of Virginia * All Rights Reserved * * This file is part of the Mentat system software library. This software * is intended for research and is available free of charge for that * purpose; however, all material is the proprietary source of the * University of Virginia, and may not be disclosed or copied in any * form without the explicit written permission of the Univeristy of * Virginia. * * This software is distributed WITHOUT ANY WARRANTY; without even the * implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR * PURPOSE. This software hereunder is provided on an "as is" basis, * and the University of Virginia has no obligation to provide maintenance, * support, updates, enhancements, or modifications. * * Send problems & suggestions to: * mentat@Virginia.EDU * ***************************************************************************/ /*-------------------------------------------------------------------------- * * Seq_persist is an application that demonstrates the use of sequential * persistent (SP) Mentat classes. It shows that invocations on a SP * Mentat object are serviced sequentially. * *------------------------------------------------------------------------*/ // STREAMS WILL NOT COMPILE WITH G++! // If using g++, remove all references to streams and use printf #include #include "reg_class.h" #include "sp_class.h" #define TIMES 5 main () { int a[10], result, k[10]; sp_class obj; reg_class reg; mfilesys mfs; MENTAT_OPEN_FS (mfs); MENTAT_ENABLE_IO (mfs); obj.create (); //Create instances of regular objects //Each instance is delayed either 0 or 1 time units //The return value is simply the order in which they //are called for (int j=1; j <=5; j++) k[j] = reg.delay (2,j); //Use the return values in reverse order of their //delay value a[1] = obj.mem3 (k[5]); a[2] = obj.mem2 (k[4]); a[3] = obj.mem1 (k[3]); a[4] = obj.mem2 (k[2]); a[5] = obj.mem3 (k[1]); //Block for all of the computations to complete //at this point by using each of the return values for (j=1; j <=TIMES; j++) if (a[j]==1); //Block for the computation to complete //at this point by using the return value result = obj.report (mfs); if (result == 0); obj.destroy(); MENTAT_DISABLE_IO (mfs); MENTAT_CLOSE_FS (mfs); }