|
Boost : |
Subject: [boost] problems with recursive_timed_mutex and scoped lock wont compile in version 1.39
From: Clark Sims (clark_sims_boost_at_[hidden])
Date: 2009-09-07 13:21:01
I can compile the following code fine in boost 1.33.1 but it generates compiler errors
in version 1.39. I am using visual studio 2005.
I will post the code, and then post the compiler errors:
#include <iostream>
#include <boost/thread/thread.hpp>
#include <boost/thread/xtime.hpp>
#include <boost/thread/recursive_mutex.hpp>
using namespace std;
//using namespace boost;
using boost::mutex;
using boost::thread;
using boost::recursive_timed_mutex;
using boost::xtime;
boost::recursive_timed_mutex hello_mutex;
void hello( int thread_id, int iter) {
cerr << thread_id << " : " << iter << endl;
}
void rand_xtime( xtime* xt) {
xtime_get( xt, boost::TIME_UTC);
//xt.nsec += (rand() % 1000000000);
xt->sec += 1 + rand()%5;
}
void say_hello( int thread_id) {
for (int iter=0; iter<5; iter++) {
xtime xt;
rand_xtime( &xt);
thread::sleep(xt);
rand_xtime( &xt);
{
recursive_timed_mutex &refer_hello = hello_mutex;
const xtime& refer_xt = xt;
recursive_timed_mutex::scoped_timed_lock
lock1( refer_hello, refer_xt);
if (lock1) {
hello( thread_id, iter);
}
}
}
}
void hello1() {
say_hello( 1);
}
void hello2() {
say_hello( 2);
}
int main() {
boost::thread thrd1(hello1);
boost::thread thrd2(hello2);
thrd1.join();
thrd2.join();
return 0;
}
Microsoft (R) Program Maintenance Utility Version 8.00.50727.42
Copyright (C) Microsoft Corporation. All rights reserved.
Warning: cannot find Makefile.TimedMutex.dep
cl.exe /nologo /Ob0 /W3 /EHs /MD /GR /I ".." /D NDEBUG /D WIN32 /D _CONSOLE /FD /c /Fo"Release\TimedMutex\I386\TimedMutex.obj" "TimedMutex.cpp"
TimedMutex.cpp
c:\boost_1_39\boost\thread\win32\basic_recursive_mutex.hpp(64) : error C2679: binary '+' : no operator found which takes a right-hand operand of type 'const boost::xtime' (or there is no acceptable conversion)
c:\boost_1_39\boost/date_time/posix_time/date_duration_operators.hpp(31): could be 'boost::posix_time::ptime boost::posix_time::operator +(const boost::posix_time::ptime &,const boost::gregorian::months &)' [found using argument-dependent lookup]
c:\boost_1_39\boost/date_time/date_duration_types.hpp(132): or 'boost::gregorian::date boost::date_time::months_duration<base_config>::operator +(const boost::gregorian::date &,const boost::date_time::months_duration<base_config> &)' [found using argument-dependent lookup]
with
[
base_config=boost::gregorian::greg_durations_config
]
c:\boost_1_39\boost/date_time/posix_time/date_duration_operators.hpp(75): or 'boost::posix_time::ptime boost::posix_time::operator +(const boost::posix_time::ptime &,const boost::gregorian::years &)' [found using argument-dependent lookup]
c:\boost_1_39\boost/date_time/date_duration_types.hpp(244): or 'boost::gregorian::date boost::date_time::years_duration<base_config>::operator +(const boost::gregorian::date &,const boost::date_time::years_duration<base_config> &)' [found using argument-dependent lookup]
with
[
base_config=boost::gregorian::greg_durations_config
]
c:\boost_1_39\boost/date_time/time.hpp(139): or 'boost::posix_time::ptime boost::date_time::base_time<T,time_system>::operator +(const boost::gregorian::date_duration &) const'
with
[
T=boost::posix_time::ptime,
time_system=boost::posix_time::posix_time_system
]
c:\boost_1_39\boost/date_time/time.hpp(159): or 'boost::posix_time::ptime boost::date_time::base_time<T,time_system>::operator +(const boost::posix_time::time_duration &) const'
with
[
T=boost::posix_time::ptime,
time_system=boost::posix_time::posix_time_system
]
while trying to match the argument list '(boost::system_time, const boost::xtime)'
c:\boost_1_39\boost/thread/locks.hpp(364) : see reference to function template instantiation 'bool boost::detail::basic_recursive_mutex_impl<underlying_mutex_type>::timed_lock<boost::xtime>(const Duration &)' being compiled
with
[
underlying_mutex_type=boost::detail::basic_timed_mutex,
Duration=boost::xtime
]
c:\boost_1_39\boost/thread/locks.hpp(363) : while compiling class template member function 'bool boost::unique_lock<Mutex>::timed_lock(const boost::xtime &)'
with
[
Mutex=boost::recursive_timed_mutex
]
TimedMutex.cpp(36) : see reference to class template instantiation 'boost::unique_lock<Mutex>' being compiled
with
[
Mutex=boost::recursive_timed_mutex
]
NMAKE : fatal error U1077: '"c:\Program Files\Microsoft Visual Studio 8\VC\BIN\cl.exe"' : return code '0x2'
Stop.
Boost list run by bdawes at acm.org, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk