문제

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