I'm using Xcode 5.0 and boost 1.54. The following code compiles fine using Visual Studio 2008 Sp1, but does not compile in Xcode:
template <class Rep, class Period>
bool try_lock_for(const boost::chrono::duration<Rep, Period> &_rel_time)
{
return m_mutex.try_lock_for(_rel_time);
}
I get the error "No member named 'try_lock_until' in 'boost::mutex'" in Xcode.
I am including boost/mutex.hpp and boost/thread.hpp. The Xcode project is setup to use Apple LLVM 5.0 and the GNU99 C++ dialect. I get a similar compile error when I use 'try_lock_until(...)'.
It seems that boost::mutex is defined differently on the two platforms. On Windows the code looks as follows:
namespace detail
{
typedef ::boost::detail::basic_timed_mutex underlying_mutex;
}
class mutex:
public ::boost::detail::underlying_mutex
{
...
}
So on Windows boost::mutex inherits from timed mutex, but on xcode its just a class that uses pthreads (without support for try_for, etc.).
What is the correct way then to use boost mutex (with try_for) for both Windows and MacOS? Any help would be appreciated.