You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
To use a ScopedAccess object, you have to know its full type, which is pretty awkward to spell out, especially inside template classes:
using ScopedReader = typename farbot::RealtimeMutatable<Data<T>>::template ScopedAccess<false>;
The client has to remember what true and false mean, which isn't obvious. An enum class IsRealtime { no, yes }; instead of a plain bool would help greatly here, as would inner using declarations for ScopedReader and ScopedWriter.
Even better, though, would be to have a [[nodiscard]] auto scopedRead() const noexcept member function directly on the RealtimeMutatable class, so that the user can just do something like this.
// no need to utter the inner typename at all!constauto reader = realtimeMutatable.scopedRead();
std::cout << *reader << '\n'; // or whatever other slow thing we're doing on the non-realtime thread
In C++17, guaranteed copy elision should mean that you can return one of these non-copyable ScopedAccess objects from a function like this.
The text was updated successfully, but these errors were encountered:
To use a ScopedAccess object, you have to know its full type, which is pretty awkward to spell out, especially inside template classes:
The client has to remember what
true
andfalse
mean, which isn't obvious. Anenum class IsRealtime { no, yes };
instead of a plain bool would help greatly here, as would innerusing
declarations forScopedReader
andScopedWriter
.Even better, though, would be to have a
[[nodiscard]] auto scopedRead() const noexcept
member function directly on the RealtimeMutatable class, so that the user can just do something like this.In C++17, guaranteed copy elision should mean that you can return one of these non-copyable ScopedAccess objects from a function like this.
The text was updated successfully, but these errors were encountered: