سؤال

I would like to create file based locking that ensures exclusive access of an associated resource. The boost:interprocess::file_lock is good for separating processes, but not good for separating threads. That problem can be solved with an additional boost::recursive_mutex if we extract the file names to unique full paths (eg. no relatively specified lock files like something/x.lock) and associate the mutexes with them.

I would like to have an easier and relatively standard way of file based locking that work for threads and processes alike.

هل كانت مفيدة؟

المحلول

Use a recursive_named_mutex instead. Works across processes as well as thread. A lot cheaper and less error prone to boost.

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top