more TDB
This commit is contained in:
parent
6d1477e693
commit
8f6ba1fc5b
|
@ -15,16 +15,16 @@
|
|||
#include "tdbInt.h"
|
||||
|
||||
struct SPCache {
|
||||
int pageSize;
|
||||
int cacheSize;
|
||||
pthread_mutex_t mutex;
|
||||
int nFree;
|
||||
SPage *pFree;
|
||||
int nPage;
|
||||
int nHash;
|
||||
SPage **pgHash;
|
||||
int nRecyclable;
|
||||
SPage lru;
|
||||
int pageSize;
|
||||
int cacheSize;
|
||||
tdb_mutex_t mutex;
|
||||
int nFree;
|
||||
SPage *pFree;
|
||||
int nPage;
|
||||
int nHash;
|
||||
SPage **pgHash;
|
||||
int nRecyclable;
|
||||
SPage lru;
|
||||
};
|
||||
|
||||
#define PCACHE_PAGE_HASH(pPgid) \
|
||||
|
@ -116,13 +116,13 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage) {
|
|||
}
|
||||
}
|
||||
|
||||
static void tdbPCacheInitLock(SPCache *pCache) { pthread_mutex_init(&(pCache->mutex), NULL); }
|
||||
static void tdbPCacheInitLock(SPCache *pCache) { tdbMutexInit(&(pCache->mutex), NULL); }
|
||||
|
||||
static void tdbPCacheClearLock(SPCache *pCache) { pthread_mutex_destroy(&(pCache->mutex)); }
|
||||
static void tdbPCacheClearLock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); }
|
||||
|
||||
static void tdbPCacheLock(SPCache *pCache) { pthread_mutex_lock(&(pCache->mutex)); }
|
||||
static void tdbPCacheLock(SPCache *pCache) { tdbMutexLock(&(pCache->mutex)); }
|
||||
|
||||
static void tdbPCacheUnlock(SPCache *pCache) { pthread_mutex_unlock(&(pCache->mutex)); }
|
||||
static void tdbPCacheUnlock(SPCache *pCache) { tdbMutexDestroy(&(pCache->mutex)); }
|
||||
|
||||
static bool tdbPCacheLocked(SPCache *pCache) {
|
||||
assert(0);
|
||||
|
|
|
@ -206,7 +206,7 @@ int tdbPagerCommit(SPager *pPager) {
|
|||
// TODO: release the page
|
||||
}
|
||||
|
||||
fsync(pPager->fd);
|
||||
tdbOsFSync(pPager->fd);
|
||||
|
||||
tdbOsClose(pPager->jfd);
|
||||
remove(pPager->jFileName);
|
||||
|
|
|
@ -45,12 +45,14 @@ typedef TdFilePtr tdb_fd_t;
|
|||
#define tdbOsRead taosReadFile
|
||||
#define tdbOsPRead taosPReadFile
|
||||
#define tdbOsWrite taosWriteFile
|
||||
#define tdbOsFSync taosFsyncFile
|
||||
#else
|
||||
#define tdbOsOpen open
|
||||
#define tdbOsClose close
|
||||
#define tdbOsRead read
|
||||
#define tdbOsPRead pread
|
||||
#define tdbOsWrite write
|
||||
#define tdbOsFSync fsync
|
||||
#endif
|
||||
|
||||
// For threads and lock
|
||||
|
@ -65,6 +67,14 @@ typedef TdThreadSpinlock tdb_spinlock_t;
|
|||
#define tdbSpinlockUnlock taosThreadSpinUnlock
|
||||
#define tdbSpinlockTrylock
|
||||
|
||||
// mutex lock
|
||||
typedef TdThreadMutex tdb_mutex_t;
|
||||
|
||||
#define tdbMutexInit taosThreadMutexInit
|
||||
#define tdbMutexDestroy taosThreadMutexDestroy
|
||||
#define tdbMutexLock taosThreadMutexLock
|
||||
#define tdbMutexUnlock taosThreadMutexUnlock
|
||||
|
||||
#else
|
||||
|
||||
// spin lock
|
||||
|
@ -76,6 +86,14 @@ typedef pthread_spinlock_t tdb_spinlock_t;
|
|||
#define tdbSpinlockUnlock pthread_spin_unlock
|
||||
#define tdbSpinlockTrylock pthread_spin_trylock
|
||||
|
||||
// mutex lock
|
||||
typedef pthread_mutex_t tdb_mutex_t;
|
||||
|
||||
#define tdbMutexInit pthread_mutex_init
|
||||
#define tdbMutexDestroy pthread_mutex_destroy
|
||||
#define tdbMutexLock pthread_mutex_lock
|
||||
#define tdbMutexUnlock pthread_mutex_unlock
|
||||
|
||||
#endif
|
||||
|
||||
#ifdef __cplusplus
|
||||
|
|
Loading…
Reference in New Issue