New to linux and c++.
I wante to create an application that only needs to run on linux (ubuntuz) and i need to use basic read-write locks.
I saw that there are a few libraries that give “concurrency capabilities”.
e.g. to use mutexes, there are at least 3 options:
-
pthread_mutex_lock (pthread.h)
-
boost::mutex
-
std::mutex (mutex)
could someone explain the differences between the various approaches?
pthreads is a C-API and is available on all posix conformant systems (
pthreadsstands forPosix THREADS).boost::mutex is a C++-only API that depends on the “boost”-library (you cannot use it in C-code; you add a dependency on “boost”)
lots of features from boost will eventually end up in the C++ standard library, e.g. threading; with C++11 you have std::mutex, but you will need a compiler recent enough to support that recent addition. e.g. if you want your application to be backportable to older distributions you might want to avoid it.