Main Page | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members | File Members

FlushQueue.H

Go to the documentation of this file.
00001 // Copyright (C) 2001, Compaq Computer Corporation
00002 // 
00003 // This file is part of Vesta.
00004 // 
00005 // Vesta is free software; you can redistribute it and/or
00006 // modify it under the terms of the GNU Lesser General Public
00007 // License as published by the Free Software Foundation; either
00008 // version 2.1 of the License, or (at your option) any later version.
00009 // 
00010 // Vesta is distributed in the hope that it will be useful,
00011 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00012 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00013 // Lesser General Public License for more details.
00014 // 
00015 // You should have received a copy of the GNU Lesser General Public
00016 // License along with Vesta; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00018 
00019 // Created on Mon Oct  6 14:09:58 PDT 1997 by heydon
00020 // Last modified on Mon May 23 22:28:00 EDT 2005 by ken@xorian.net  
00021 //      modified on Sat Feb 12 13:13:55 PST 2000 by mann  
00022 //      modified on Mon Oct  6 14:41:45 PDT 1997 by heydon
00023 
00024 // FlushQueue.H -- an object for synchronizing flusher threads
00025 
00026 #ifndef _FLUSH_QUEUE_H
00027 #define _FLUSH_QUEUE_H
00028 
00029 #include <Basics.H>
00030 #include <Sequence.H>
00031 
00032 class FlushQueue {
00033   public:
00034     FlushQueue(Basics::mutex *mu) throw () : mu(mu), numRunning(0) { /*SKIP*/ }
00035     /* Initialize the queue to be protected by the mutex "mu". This mutex is
00036        denoted in the method preconditions below by "SELF.mu". */
00037 
00038     void Enqueue() throw ();
00039     /* REQUIRES Sup(LL) = SELF.mu */
00040     /* Add the calling thread to this queue. The thread will block until the
00041        threads ahead of it in the queue have been dequeued. */
00042 
00043     void Dequeue() throw ();
00044     /* REQUIRES Sup(LL) = SELF.mu */
00045     /* Signal the next thread in the queue that it can run. */
00046 
00047   private:
00048     typedef Sequence<Basics::cond*> CondSeq;
00049 
00050     Basics::mutex *mu;
00051     int numRunning;
00052     CondSeq seq;
00053 
00054     /* The field "numRunning" counts the number of threads that have returned
00055        from "Enqueue" but that have yet to call "Dequeue". It will always be
00056        either 0 or 1, so it could have been represented by the type "bool",
00057        but representing it by an integer allows additional assertion checking.
00058     */
00059 };
00060 
00061 #endif // _FLUSH_QUEUE_H

Generated on Mon May 8 00:48:34 2006 for Vesta by  doxygen 1.4.2