提交 8f6ba1fc 编写于 作者: H Hongze Cheng

more TDB

上级 6d1477e6
...@@ -17,7 +17,7 @@ ...@@ -17,7 +17,7 @@
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;
...@@ -116,13 +116,13 @@ void tdbPCacheRelease(SPCache *pCache, SPage *pPage) { ...@@ -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) { ...@@ -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; ...@@ -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; ...@@ -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; ...@@ -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
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册