On 17-Dec-14 21:11, Matthew Woehlke wrote:
On 2014-10-13 10:39, Brad King wrote:
On 10/10/2014 07:45 AM, Ruslan Baratov wrote:
Locking directory is equivalent to locking file `cmake.lock` in
directory "/path/to/shared/directory/":
I think this can be activated buy a DIRECTORY option.
Why do we need even that? Can't CMake just test if the lock target is a
directory?
I've used boost.interprocess as a hint for implementation, as far as I know boost::interprocess::file_lock is not able to lock directories: terminate called after throwing an instance of 'boost::interprocess::interprocess_exception'
    what():  Is a directory

I'm not saying that it's not possible, just trying to use well-known cross-platform solution.

p.s. For a lock with no timeout, maybe there can be a built-in timeout
after which CMake displays a message what it's trying to do, so that it
doesn't just hang mysteriously.
You can use `message` command:

    message(STATUS "Try to lock ${file}")
    file(LOCK ${file})

or more complex (more user-friendly):

  while(TRUE)
    file(LOCK "${file}" RESULT is_locked TIMEOUT 5)
    if(is_locked)
      message("Locked. ${resource_info}")
      break()
    endif()
    string(TIMESTAMP time_now "%S/%M")
    message("[${time_now}] Lock failed, retry... (file: ${file})")
  endwhile()


Ruslo
--

Powered by www.kitware.com

Please keep messages on-topic and check the CMake FAQ at: 
http://www.cmake.org/Wiki/CMake_FAQ

Kitware offers various services to support the CMake community. For more 
information on each offering, please visit:

CMake Support: http://cmake.org/cmake/help/support.html
CMake Consulting: http://cmake.org/cmake/help/consulting.html
CMake Training Courses: http://cmake.org/cmake/help/training.html

Visit other Kitware open-source projects at 
http://www.kitware.com/opensource/opensource.html

Follow this link to subscribe/unsubscribe:
http://public.kitware.com/mailman/listinfo/cmake-developers

Reply via email to