General question concerning the implimentation of mutexes.
I am using mutexes to synchronize data access of a object shared by multiple threads. It seems like the only practical place to use the lock/unlock functions are within the actual data class itself (ie. get/set functions). The actual "shared" data object is a container class consisting of a number of these data classes. Is it possible for me to just simpily use mutexes in the container class or do I need to go the long route and pass the mutex variable (pthread_mutex_t mutex) all the way down to the data element class and use lock/unlock anytime a variable is "set/get". If this is the case, is there a lot of overhead in using the mutex functionality anytime a variable is accessed?
Thanks.