From c7c456e9f91b83ec881e416ae133bc97022c6e3e Mon Sep 17 00:00:00 2001 From: Nadav Har'El <nyh@cloudius-systems.com> Date: Wed, 26 Jun 2013 14:40:50 +0300 Subject: [PATCH] Fix build error Change lockfree::mutex to use "protected" instead of "private". This allows tst-mutex to extend it and mess with the internals (I want to modify count, to benchmark the rare "handoff" case). Sorry about the build error. --- include/lockfree/mutex.hh | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/include/lockfree/mutex.hh b/include/lockfree/mutex.hh index ed653f905..6abb54095 100644 --- a/include/lockfree/mutex.hh +++ b/include/lockfree/mutex.hh @@ -54,7 +54,7 @@ namespace sched { namespace lockfree { class mutex { -private: +protected: std::atomic<int> count; // "owner" and "depth" are only used for implementing a recursive mutex. // "depth" is not an atomic variable - only the lock-owning thread sets @@ -67,6 +67,9 @@ private: std::atomic<unsigned int> handoff; unsigned int sequence; public: + // Note: mutex's constructor just initializes the whole structure to + // zero, and its destructor does nothing. This is useful to know when + // allocating a mutex in C. mutex() : count(0), depth(0), owner(nullptr), waitqueue(), handoff(0), sequence(0) { } ~mutex() { /*assert(count==0);*/ } -- GitLab