Changing default value for MAX_THREAD to 10
[csql.git] / include / Lock.h
blob6bbe751d051d6209d8ce825d18ef4ea9f1bbbfe2
1 /***************************************************************************
2 * Copyright (C) 2007 by www.databasecache.com *
3 * Contact: praba_tuty@databasecache.com *
4 * *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 * *
10 * This program is distributed in the hope that it will be useful, *
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of *
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the *
13 * GNU General Public License for more details. *
14 * *
15 ***************************************************************************/
16 #ifndef LOCK_H
17 #define LOCK_H
18 #include<os.h>
19 #include<Index.h>
20 class Chunk;
21 class Database;
22 class Transaction;
24 class LockInfo
26 public:
27 signed int noOfReaders_;
28 //-1 indicates write lock is taken
30 unsigned char waitReaders_;
31 unsigned char waitWriters_;
32 LockInfo() { noOfReaders_ = 0; waitReaders_ = 0; waitWriters_ = 0; }
35 class LockHashNode
37 public:
38 void *ptrToTuple_;
39 LockInfo lInfo_;
40 LockHashNode *next_;
43 class LockListIter
45 LockHashNode *iter;
46 public:
47 LockListIter(){}
48 LockListIter(LockHashNode *head) { iter = head;}
49 LockHashNode* next();
50 friend class LockList;
53 class TransHasNode
55 public:
56 LockHashNode *node_;
57 TransHasNode *next_;
60 class DatabaseManagerImpl;
61 //singleton
62 //DatabaseManager has this object and give reference to it to
63 //Table interface and so on.
64 class LockManager
66 public:
67 Database *systemDatabase_;
69 private:
70 LockHashNode* allocLockNode(LockInfo &info, void *tuple);
71 void deallocLockNode(LockHashNode *head, Bucket *bucket);
72 Bucket* getLockBucket(void *tuple);
74 public:
76 LockManager(Database *sysDb_){ systemDatabase_ = sysDb_;}
77 DbRetVal getSharedLock(void *tuple, Transaction **trans);
78 DbRetVal getExclusiveLock(void * tuple, Transaction **trans);
79 DbRetVal releaseLock(void *tuple);
80 DbRetVal isExclusiveLocked(void *tuple, bool &status);
84 #endif