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

View File

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