Main Page   Class Hierarchy   Compound List   File List   Compound Members   Related Pages  

rnglock.h

00001 //
00002 // rnglock.h
00003 //
00004 // Copyright (C) 1996 Limit Point Systems, Inc.
00005 //
00006 // Author: Curtis Janssen <cljanss@limitpt.com>
00007 // Maintainer: LPS
00008 //
00009 // This file is part of the SC Toolkit.
00010 //
00011 // The SC Toolkit is free software; you can redistribute it and/or modify
00012 // it under the terms of the GNU Library General Public License as published by
00013 // the Free Software Foundation; either version 2, or (at your option)
00014 // any later version.
00015 //
00016 // The SC Toolkit is distributed in the hope that it will be useful,
00017 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00018 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00019 // GNU Library General Public License for more details.
00020 //
00021 // You should have received a copy of the GNU Library General Public License
00022 // along with the SC Toolkit; see the file COPYING.LIB.  If not, write to
00023 // the Free Software Foundation, 675 Mass Ave, Cambridge, MA 02139, USA.
00024 //
00025 // The U.S. Government is granted a limited license as per AL 91-7.
00026 //
00027 
00028 #ifdef __GNUC__
00029 #pragma interface
00030 #endif
00031 
00032 #ifndef _util_group_rnglock_h
00033 #define _util_group_rnglock_h
00034 
00035 #include <iostream>
00036 
00037 #include <util/misc/exenv.h>
00038 
00039 class Pool;
00040 
00041 class RangeLockItem {
00042   public:
00043     RangeLockItem *prev;
00044     RangeLockItem *next;
00045     int start;
00046     int fence;
00047     int value;
00048     RangeLockItem(RangeLockItem *p, RangeLockItem *n, int s, int f, int v):
00049       prev(p), next(n), start(s), fence(f), value(v) {}
00050     ~RangeLockItem() {};
00051 
00052     static void *operator new(size_t, Pool *);
00053     static void operator delete(void *, Pool *);
00054 };
00055 
00056 class RangeLockValOp;
00057 class RangeLock {
00058   private:
00059     RangeLockItem *root_;
00060     Pool *pool_;
00061 
00062     void split_ranges(int start, int fence);
00063     void do_valop(RangeLockValOp&, int start, int fence);
00064   public:
00065     RangeLock(Pool *pool = 0);
00066     ~RangeLock();
00067 
00068     void increment(int start, int fence);
00069     void decrement(int start, int fence);
00070     void set(int start, int fence, int value);
00071     void sum(int start, int fence, int delta);
00072 
00073     // check for anything within a range to be equal to a value
00074     int checkeq(int start, int fence, int value);
00075     // check for anything within a range to be greater than a value
00076     int checkgr(int start, int fence, int value);
00077 
00078     void check();
00079     void print(std::ostream &o = ExEnv::out()) const;
00080 
00081     int lockvalue(int i);
00082 };
00083 
00084 #endif
00085 
00086 // Local Variables:
00087 // mode: c++
00088 // c-file-style: "CLJ"
00089 // End:

Generated at Thu Oct 4 18:08:47 2001 for MPQC 2.0.0 using the documentation package Doxygen 1.2.5.