![]()
|
rnglock.h00001 //
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 namespace sc {
00040
00041 class Pool;
00042
00043 class RangeLockItem {
00044 public:
00045 RangeLockItem *prev;
00046 RangeLockItem *next;
00047 int start;
00048 int fence;
00049 int value;
00050 RangeLockItem(RangeLockItem *p, RangeLockItem *n, int s, int f, int v):
00051 prev(p), next(n), start(s), fence(f), value(v) {}
00052 ~RangeLockItem() {};
00053
00054 static void *operator new(size_t, Pool *);
00055 static void operator delete(void *, Pool *);
00056 };
00057
00058 class RangeLockValOp;
00059 class RangeLock {
00060 private:
00061 RangeLockItem *root_;
00062 Pool *pool_;
00063
00064 void split_ranges(int start, int fence);
00065 void do_valop(RangeLockValOp&, int start, int fence);
00066 public:
00067 RangeLock(Pool *pool = 0);
00068 ~RangeLock();
00069
00070 void increment(int start, int fence);
00071 void decrement(int start, int fence);
00072 void set(int start, int fence, int value);
00073 void sum(int start, int fence, int delta);
00074
00075 // check for anything within a range to be equal to a value
00076 int checkeq(int start, int fence, int value);
00077 // check for anything within a range to be greater than a value
00078 int checkgr(int start, int fence, int value);
00079
00080 void check();
00081 void print(std::ostream &o = ExEnv::out0()) const;
00082
00083 int lockvalue(int i);
00084 };
00085
00086 }
00087
00088 #endif
00089
00090 // Local Variables:
00091 // mode: c++
00092 // c-file-style: "CLJ"
00093 // End:
Generated at Fri Jan 10 08:14:09 2003 for MPQC 2.1.3 using the documentation package Doxygen 1.2.14. |