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