code reorg and doxygen documentation
[csql.git] / src / storage / PageInfo.cxx
blob2a7c6689552856b84b83c37f11621a93d7726aa0
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 #include<Allocator.h>
17 #include<os.h>
18 #include<Config.h>
19 #include<Debug.h>
21 void PageInfo::setPageAsFree()
23 int ret = Mutex::CASGen(&isUsed_, isUsed_, 0);
24 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
25 ret = Mutex::CASGen(&flags , flags, 0);;
26 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
27 ret = Mutex::CASL((long*)&nextPage_, (long)nextPage_, 0);
28 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
29 ret = Mutex::CASL((long*)&nextPageAfterMerge_, (long)nextPageAfterMerge_, 0);
30 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
31 return;
34 void PageInfo::setPageAsUsed(size_t offset)
36 int ret = Mutex::CAS(&isUsed_, isUsed_,1);
37 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
38 InUse flagToSet=0;
39 SETBIT(flagToSet, HAS_SPACE);
40 ret = Mutex::CASGen(&flags, flags, flagToSet);;
41 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
42 ret = Mutex::CASL((long*)&nextPage_, (long)nextPage_, 0);
43 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
44 if (PAGE_SIZE > offset) {
45 ret = Mutex::CASL((long*)&nextPageAfterMerge_, (long)nextPageAfterMerge_, 0);
46 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
47 } else {
48 ret = Mutex::CASL((long*)&nextPageAfterMerge_,
49 (long) nextPageAfterMerge_ ,
50 (long)(((char*)this)+ offset));
51 if (ret != 0) printError(ErrSysFatal, "Fatal:CAS Failed");
53 return;