From f9043e98fe7f01056b9829f8b9ff50d38b10b66b Mon Sep 17 00:00:00 2001 From: Hongze Cheng Date: Fri, 4 Mar 2022 09:59:31 +0000 Subject: [PATCH] more TDB --- source/libs/tdb/src/inc/tdbPage.h | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index 07325c353e..e5a7872845 100644 --- a/source/libs/tdb/src/inc/tdbPage.h +++ b/source/libs/tdb/src/inc/tdbPage.h @@ -78,9 +78,15 @@ struct SPage { // For page ref (TODO: Need atomic operation) #define TDB_INIT_PAGE_REF(pPage) ((pPage)->nRef = 0) -#define TDB_REF_PAGE(pPage) (++(pPage)->nRef) -#define TDB_UNREF_PAGE(pPage) (--(pPage)->nRef) -#define TDB_PAGE_REF(pPage) ((pPage)->nRef) +#if 0 +#define TDB_REF_PAGE(pPage) (++(pPage)->nRef) +#define TDB_UNREF_PAGE(pPage) (--(pPage)->nRef) +#define TDB_PAGE_REF(pPage) ((pPage)->nRef) +#else +#define TDB_REF_PAGE(pPage) atomic_add_fetch_32(&((pPage)->nRef), 1) +#define TDB_UNREF_PAGE(pPage) atomic_sub_fetch_32(&((pPage)->nRef), 1) +#define TDB_PAGE_REF(pPage) atomic_load_32(&((pPage)->nRef)) +#endif #ifdef __cplusplus } -- GitLab