Uploaded image for project: 'OpenVDB'
  1. OpenVDB
  2. OVDB-33

Fix Thread Safety of AttributeArray Copy Constructor

XMLWordPrintable

    • Icon: Improvement Improvement
    • Resolution: Done
    • Icon: Medium Medium
    • OpenVDB_7.0.0
    • None
    • Points

      Currently, the copy constructor of an AttributeArray is not thread-safe because it doesn't lock the mutex when initializing the variables around performing the copy.

      The best pattern I've found to address this is the following:

      class Foo {
      private:
          Foo(const Foo& other, const tbb::spin_mutex::scoped_lock&)
              : var(other.var) { }
      public:
          Foo(const Foo& other)
              : Foo(other, tbb::spin_mutex::scoped_lock(other.mMutex)) { }
      };
      

      However, this requires an ABI=7 change.

            danrbailey danrbailey
            danrbailey danrbailey
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: