Commit 0e4a66a1 authored by Jakub Klinkovský's avatar Jakub Klinkovský
Browse files

Reordered initialization of members in SharedPointer and DevicePointer

This is for consistency and also to avoid compiler warnings
parent 0dff62ab
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -210,8 +210,8 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
      typedef DevicePointer< Object, Devices::Cuda > ThisType;

      explicit  DevicePointer( ObjectType& obj )
      : counter( 0 ), cuda_pointer( 0 ),
        pointer( 0 ), modified( false )
      : pointer( 0 ), cuda_pointer( 0 ),
        counter( 0 ), modified( false )
      {
         this->counter = new int( 1 );
         this->pointer = &obj;
@@ -252,8 +252,8 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
      {
         pointer.pointer = nullptr;
         pointer.cuda_pointer = nullptr;
         pointer.modified = false;
         pointer.counter = nullptr;
         pointer.modified = false;
      }

      // conditional constructor for non-const -> const data
@@ -267,8 +267,8 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
      {
         pointer.pointer = nullptr;
         pointer.cuda_pointer = nullptr;
         pointer.modified = false;
         pointer.counter = nullptr;
         pointer.modified = false;
      }

      const Object* operator->() const
@@ -335,8 +335,8 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         *( this->counter ) += 1;
         return *this;
      }
@@ -349,8 +349,8 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         *( this->counter ) += 1;
         return *this;
      }
@@ -361,12 +361,12 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         ptr.pointer = nullptr;
         ptr.cuda_pointer = nullptr;
         ptr.modified = false;
         ptr.counter = nullptr;
         ptr.modified = false;
         return *this;
      }

@@ -378,12 +378,12 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         ptr.pointer = nullptr;
         ptr.cuda_pointer = nullptr;
         ptr.modified = false;
         ptr.counter = nullptr;
         ptr.modified = false;
         return *this;
      }

@@ -432,9 +432,9 @@ class DevicePointer< Object, Devices::Cuda > : public SmartPointer

      Object *pointer, *cuda_pointer;

      bool modified;

      int* counter;

      bool modified;
};

} // namespace TNL
+12 −12
Original line number Diff line number Diff line
@@ -308,8 +308,8 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer

      template< typename... Args >
      explicit  SharedPointer( Args... args )
      : counter( 0 ), cuda_pointer( 0 ),
        pointer( 0 ), modified( false )
      : pointer( 0 ), cuda_pointer( 0 ),
        counter( 0 ), modified( false )
      {
         if( ! lazy )
         {
@@ -356,8 +356,8 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
      {
         pointer.pointer = nullptr;
         pointer.cuda_pointer = nullptr;
         pointer.modified = false;
         pointer.counter = nullptr;
         pointer.modified = false;
      }

      // conditional constructor for non-const -> const data
@@ -371,8 +371,8 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
      {
         pointer.pointer = nullptr;
         pointer.cuda_pointer = nullptr;
         pointer.modified = false;
         pointer.counter = nullptr;
         pointer.modified = false;
      }

      template< typename... Args >
@@ -480,8 +480,8 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         *( this->counter ) += 1;
#ifdef TNL_DEBUG_SHARED_POINTERS
         std::cerr << "Copy-assigned shared pointer: counter = " << *(this->counter) << ", type: " << demangle(typeid(ObjectType).name()) << std::endl;
@@ -497,8 +497,8 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         *( this->counter ) += 1;
#ifdef TNL_DEBUG_SHARED_POINTERS
         std::cerr << "Copy-assigned shared pointer: counter = " << *(this->counter) << ", type: " << demangle(typeid(ObjectType).name()) << std::endl;
@@ -512,12 +512,12 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         ptr.pointer = nullptr;
         ptr.cuda_pointer = nullptr;
         ptr.modified = false;
         ptr.counter = nullptr;
         ptr.modified = false;
#ifdef TNL_DEBUG_SHARED_POINTERS
         std::cerr << "Move-assigned shared pointer: counter = " << *(this->counter) << ", type: " << demangle(typeid(ObjectType).name()) << std::endl;
#endif
@@ -532,12 +532,12 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer
         this->free();
         this->pointer = ptr.pointer;
         this->cuda_pointer = ptr.cuda_pointer;
         this->modified = ptr.modified;
         this->counter = ptr.counter;
         this->modified = ptr.modified;
         ptr.pointer = nullptr;
         ptr.cuda_pointer = nullptr;
         ptr.modified = false;
         ptr.counter = nullptr;
         ptr.modified = false;
#ifdef TNL_DEBUG_SHARED_POINTERS
         std::cerr << "Move-assigned shared pointer: counter = " << *(this->counter) << ", type: " << demangle(typeid(ObjectType).name()) << std::endl;
#endif
@@ -601,9 +601,9 @@ class SharedPointer< Object, Devices::Cuda, lazy > : public SmartPointer

      Object *pointer, *cuda_pointer;

      bool modified;

      int* counter;

      bool modified;
};

} // namespace TNL