Skip to content

Instantly share code, notes, and snippets.

@picanumber
Last active August 9, 2021 15:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save picanumber/094a17852916e536b69fcaf1ec147b16 to your computer and use it in GitHub Desktop.
Save picanumber/094a17852916e536b69fcaf1ec147b16 to your computer and use it in GitHub Desktop.
template <class T> class Locking
{
T _data;
mutable std::recursive_mutex _mtx;
/* Define call proxy here */
public:
template <class U> Locking(U &&data) : _data(std::forward<U>(data))
{
}
CallProxy<T> operator->()
{
_mtx.lock();
return CallProxy<T>(&_data, _mtx);
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment