more
This commit is contained in:
parent
8d7e5385cc
commit
e9de08c35d
|
@ -45,6 +45,7 @@ static SPage *tdbPCacheFetchImpl(SPCache *pCache, const SPgid *pPgid, bool alcNe
|
||||||
static void tdbPCachePinPage(SPage *pPage);
|
static void tdbPCachePinPage(SPage *pPage);
|
||||||
static void tdbPCacheRemovePageFromHash(SPage *pPage);
|
static void tdbPCacheRemovePageFromHash(SPage *pPage);
|
||||||
static void tdbPCacheAddPageToHash(SPage *pPage);
|
static void tdbPCacheAddPageToHash(SPage *pPage);
|
||||||
|
static void tdbPCacheUnpinPage(SPage *pPage);
|
||||||
|
|
||||||
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache) {
|
int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCache) {
|
||||||
SPCache *pCache;
|
SPCache *pCache;
|
||||||
|
@ -89,8 +90,16 @@ void tdbPCacheFetchFinish(SPCache *pCache, SPage *pPage) {
|
||||||
pPage->nRef++; // TODO: do we need atomic operation???
|
pPage->nRef++; // TODO: do we need atomic operation???
|
||||||
}
|
}
|
||||||
|
|
||||||
void tdbPCacheRelease(SPage *pHdr) {
|
void tdbPCacheRelease(SPage *pPage) {
|
||||||
|
pPage->nRef--;
|
||||||
|
if (pPage->nRef == 0) {
|
||||||
|
if (1 /*TODO: page still clean*/) {
|
||||||
|
tdbPCacheUnpinPage(pPage);
|
||||||
|
} else {
|
||||||
// TODO
|
// TODO
|
||||||
|
ASSERT(0);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
static void tdbPCacheInitLock(SPCache *pCache) { pthread_mutex_init(&(pCache->mutex), NULL); }
|
static void tdbPCacheInitLock(SPCache *pCache) { pthread_mutex_init(&(pCache->mutex), NULL); }
|
||||||
|
@ -167,6 +176,18 @@ static void tdbPCachePinPage(SPage *pPage) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void tdbPCacheUnpinPage(SPage *pPage) {
|
||||||
|
// Add current page to the LRU list
|
||||||
|
SPCache *pCache;
|
||||||
|
|
||||||
|
pPage->pLruPrev = &(pCache->lru);
|
||||||
|
pPage->pLruNext = pCache->lru.pLruNext;
|
||||||
|
pCache->lru.pLruNext->pLruPrev = pPage;
|
||||||
|
pCache->lru.pLruNext = pPage;
|
||||||
|
|
||||||
|
pCache->nRecyclable++;
|
||||||
|
}
|
||||||
|
|
||||||
static void tdbPCacheRemovePageFromHash(SPage *pPage) {
|
static void tdbPCacheRemovePageFromHash(SPage *pPage) {
|
||||||
SPCache *pCache;
|
SPCache *pCache;
|
||||||
SPage ** ppPage;
|
SPage ** ppPage;
|
||||||
|
|
|
@ -44,7 +44,7 @@ int tdbPCacheOpen(int pageSize, int cacheSize, int extraSize, SPCache **ppCac
|
||||||
int tdbPCacheClose(SPCache *pCache);
|
int tdbPCacheClose(SPCache *pCache);
|
||||||
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
|
SPage *tdbPCacheFetch(SPCache *pCache, const SPgid *pPgid, bool alcNewPage);
|
||||||
void tdbPCacheFetchFinish(SPCache *pCache, SPage *pPage);
|
void tdbPCacheFetchFinish(SPCache *pCache, SPage *pPage);
|
||||||
void tdbPCacheRelease(SPage *pHdr);
|
void tdbPCacheRelease(SPage *pPage);
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue