[cmake-developers] New command 'file(LOCK_DIRECTORY ...)'

Brad King brad.king at kitware.com
Wed Oct 29 09:48:47 EDT 2014


On 10/28/2014 04:28 PM, Ruslan Baratov wrote:
> What do you think about this:

Thanks for drafting the signature.

> file(
>      LOCK <path>
>      [DIRECTORY] # if present locked file will be <path>/cmake.lock 
> (instead of <path>)
>      [RELEASE] # do explicit unlock
>      [GUARD <FUNCTION|FILE|PROCESS>] # if not present - set to `GUARD 
> PROCESS` (not used if RELEASE)
>      [RESULT_VARIABLE <variable>] # 0 on success, error message 
> otherwise; if not present - any error is FATAL_ERROR
>      [TIMEOUT <seconds>]
>          # 0 - return immediately if operation failed (try_lock), 
> otherwise timeout (timed_lock);
>          # if not present - lock until success (or error);
>          # not used if RELEASE;
> )

That looks good.  The TIMEOUT unit can be 'seconds' but it should
accept a floating point value to get shorter times if possible.

> Boost implementation of file locking mechanism use 
> LockFileEx/UnlockFileEx for windows and fcntl for unix-like platforms.
> These functions lock file only for current process. When process crashes 
> lock removed by OS automatically.

Great!

> I've tried (Un)LockFileEx/fcntl on windows (including mingw and cygwin), 
> linux and mac - works fine for me with one exception: cygwin's lock is 
> not visible by win32's lock. I.e. you can synchronize multiple cygwin 
> processes and multiple windows "normal" processes, but you can't mix them.

Thanks for testing.  The windows/cygwin mixing limitation is acceptable
IMO.

Thanks,
-Brad



More information about the cmake-developers mailing list