more work

This commit is contained in:
Hongze Cheng 2022-02-07 03:51:02 +00:00
parent 218ab32666
commit a195e51c9f
2 changed files with 12 additions and 11 deletions

View File

@ -22,20 +22,17 @@ struct SPage {
typedef TD_DLIST(SPage) SPgList;
struct SPgCache {
SPage *pages;
SPgList freeList;
SRWLatch mutex;
pgsize_t pgsize;
SPage * pages;
SPgList freeList;
struct {
int32_t nbucket;
struct {
SRWLatch latch;
TD_DLIST(SPage) ht;
} * buckets;
int32_t nbucket;
SPgList *buckets;
} pght; // page hash table
};
int pgCacheCreate(SPgCache **ppPgCache) {
int pgCacheCreate(SPgCache **ppPgCache, pgsize_t pgsize) {
SPgCache *pPgCache;
pPgCache = (SPgCache *)calloc(1, sizeof(*pPgCache));
@ -43,6 +40,10 @@ int pgCacheCreate(SPgCache **ppPgCache) {
return -1;
}
pPgCache->pgsize = pgsize;
taosInitRWLatch(&(pPgCache->mutex));
*ppPgCache = pPgCache;
return 0;
}

View File

@ -24,7 +24,7 @@ typedef struct SPgCache SPgCache;
typedef struct SPage SPage;
// SPgCache
int pgCacheCreate(SPgCache **ppPgCache);
int pgCacheCreate(SPgCache **ppPgCache, pgsize_t pgsize);
int pgCacheDestroy(SPgCache *pPgCache);
int pgCacheOpen(SPgCache *pPgCache);
int pgCacheClose(SPgCache *pPgCache);