-
Notifications
You must be signed in to change notification settings - Fork 32
Open
Description
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!
const auto reader = realtimeMutatable.scopedRead();
std::cout << *reader << '\n'; // or whatever other slow thing we're doing on the non-realtime threadIn C++17, guaranteed copy elision should mean that you can return one of these non-copyable ScopedAccess objects from a function like this.
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels