LouisCharlesC / safe

Header only read/write wrapper for mutexes and locks.
MIT License
147 stars 11 forks source link

Suggestions #2

Closed ahoarau closed 5 years ago

ahoarau commented 5 years ago
  1. A method to replace the protected variable :
    safe::Safe<int> m_count{0};
    m_count = 20; // equivalent to *m_count.access() = 20;
  2. A method to get a copy of the protected variable :
    safe::Safe<int> m_count{0};
    auto count_copy = m_count.getCopy(); // equivalent to auto copy = *m_count.access();
LouisCharlesC commented 5 years ago

These suggestions will not be integrated into safe, because the primary purpose of safe is to force the programmer to either write access or unsafe. However, I am working on a small wrapper class I call State that provides a simple set, get, etc. interface for shared objects. This will be part of my mess repo.