Mutex C++

C++11 has added many improvements to help us developing multi-thread systems. I'm going to talk about mutex.

In previous C++11 compiler versions, we can get a pthread mutex, but we must initialize and destroy in C style; in the end you must do more things than just lock/unlock.

C++11 provides mutex class, we just lock/unclock the object. I recommend you take a look at C++11 mutex class.

If you still work with previous C++11 compiler versions, a time ago, I made a wrapper class that helps to work with pthread mutex. You just lock/unlock the Mutex object.

Then I leave my code proposal (Gist code).

Comments

Comments powered by Disqus