Skip to content

Instantly share code, notes, and snippets.

@rajkumar-p
Last active March 11, 2020 18:44
Show Gist options
  • Save rajkumar-p/11a7d3f7e364cecb6b5ca329d6b30b9f to your computer and use it in GitHub Desktop.
Save rajkumar-p/11a7d3f7e364cecb6b5ca329d6b30b9f to your computer and use it in GitHub Desktop.
NodeListWithLock Class
template<typename T>
class NodeListWithLock
{
private:
T _data;
std::mutex _mux;
public:
NodeListWithLock<T> _next;
public:
NodeListWithLock(T data);
T data();
void lock_node();
void unlock_node();
};
...
template<typename T>
void NodeListWithLock<T>::lock_node()
{
this->_mux.lock();
}
template<typename T>
void NodeListWithLock<T>::unlock_node()
{
this->_mux.unlock();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment