diff --git a/source/libs/tdb/src/inc/tdbPage.h b/source/libs/tdb/src/inc/tdbPage.h index 07325c353e8421dc19610da547da58627bfd1893..e5a78728455b590585c0fb66dfe8d3c01cef6a74 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 }