提交 a195e51c 编写于 作者: H Hongze Cheng

more work

上级 218ab326
...@@ -22,20 +22,17 @@ struct SPage { ...@@ -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) { ...@@ -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;
} }
......
...@@ -24,7 +24,7 @@ typedef struct SPgCache SPgCache; ...@@ -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);
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册