noexcept move for BaseHandle/InstrusivePtr/Math
[platform/core/uifw/dali-core.git] / dali / public-api / object / ref-object.h
index 72b9638..5aab626 100644 (file)
@@ -1,8 +1,8 @@
-#ifndef __DALI_REF_OBJECT_H__
-#define __DALI_REF_OBJECT_H__
+#ifndef DALI_REF_OBJECT_H
+#define DALI_REF_OBJECT_H
 
 /*
- * Copyright (c) 2015 Samsung Electronics Co., Ltd.
+ * Copyright (c) 2022 Samsung Electronics Co., Ltd.
  *
  * Licensed under the Apache License, Version 2.0 (the "License");
  * you may not use this file except in compliance with the License.
  */
 
 // EXTERNAL INCLUDES
+#include <atomic>
+#include <cstdint> // uint32_t
+
+// INTERNAL INCLUDES
 #include <dali/public-api/common/dali-common.h>
 #include <dali/public-api/common/intrusive-ptr.h>
 
@@ -38,10 +42,9 @@ class Value;
  * instead of calling Reference() and Unreference() methods directly.
  * @SINCE_1_0.0
  */
-class DALI_IMPORT_API RefObject
+class DALI_CORE_API RefObject
 {
 public:
-
   /**
    * @brief Increments the object's reference count.
    * @SINCE_1_0.0
@@ -62,10 +65,9 @@ public:
    * @SINCE_1_0.0
    * @return The reference count
    */
-  int ReferenceCount();
+  uint32_t ReferenceCount();
 
 protected:
-
   /**
    * @brief Default constructor.
    * @SINCE_1_0.0
@@ -99,9 +101,13 @@ protected:
    */
   RefObject& operator=(const RefObject& rhs);
 
-private:
+  // Not movable
+
+  RefObject(RefObject&& rhs) = delete;            ///< Deleted move constructor
+  RefObject& operator=(RefObject&& rhs) = delete; ///< Deleted move assignment operator
 
-  volatile int mCount; ///< Reference count
+private:
+  std::atomic_uint32_t mCount{0u}; ///< Reference count
 };
 
 /**
@@ -109,4 +115,4 @@ private:
  */
 } // namespace Dali
 
-#endif // __DALI_REF_OBJECT_H__
+#endif // DALI_REF_OBJECT_H