Hi,
>which boost version are you referring to?
I am using boost 1.41.0
>Also, if you can compile yout code with -g -O0 -DNDEBUG, is the behaviour
>reproducible?
Yes it is always reproducible
>If so, can you step the timed_wait() function in debugger,
>do you see anything strange?
OK I will check it, but I didn't use debugger before well I try it.
Actually I doubt the way I am using exitTime variable. exitTime valiable is defined like below in a class ASemaphore, but it is not initialized with xtime_get() function. I doubt due to this, undefined behaviour(timed_wait is not waiting) is occurring.
class ASemaphore
{
protected:
boost::xtime exitTime;
}
int ASemaphore::waitForAction()
{
boost::xtime curTime;
boost::xtime_get(&curTime, boost::TIME_UTC);
this->exitTime.sec = curTime.sec + argTotalWaitInterval;
boost::mutex::scoped_lock lock(this->mutex);
ret = this->condition.timed_wait(lock, this->exitTime);
}
when I use it like below (without using temporary variable curTime and initialize exitTime with xtime_get) timed_wait do what is expected in both the case i.e. with NDEBUG and without NDEBUG
{
boost::xtime_get(&this->exitTime, boost::TIME_UTC);
this->exitTime.sec += argTotalWaitInterval;
boost::mutex::scoped_lock lock(this->mutex);
ret = this->condition.timed_wait(lock, this->exitTime);
}
Please let me know if you can possibly guess what could be wrong.
>Happy hunting ;)
Yes I like hunting ;)
Thanking you.
Vishal
-----Original Message-----
From: boost-users-bounces@lists.boost.org on behalf of Viatcheslav.Sysoltsev@h-d-gmbh.de
Sent: Thu 2/3/2011 9:05 PM
To: boost-users@lists.boost.org
Subject: Re: [Boost-users] compilation flag effect onboost::condition::timed_wait()
> Dear All,
>
> I am getting different behaviour of condition::timed_wait() function
> when I compile my code with NDEBUG flag and without NDEBUG flag.
>
> with using NDEBUG flag, timed_wait() wait for condition (mutext) as
> desired but whey I don't use NDEBUG flag while compiling my code it does
> wait for condition (mutex) but return at the same time when it is
> called. In both the cases return value is 1.
>
> Please note that it is not a race condition but it is happening every
> time.
>
> Also note that I am using other flags too for compiling my code like
>
> -Werror -pthread -fno-strict-aliasing -Wno-unused-variable
> -Wno-unused-parameter -Wno-unused-function -O3 -ggdb3 -m64
>
>
> Please let me know what can be possible impact of NDEBUG flag on
> timed_wait() function.
>
>
> Thanking you
> Vishal
Hi Vishal,
which boost version are you referring to? The 1.45 is a little different
from previous releases in condition_variable_any.
Also, if you can compile yout code with -g -O0 -DNDEBUG, is the behaviour
reproducible? If so, can you step the timed_wait() function in debugger,
do you see anything strange?
Consider as well, most sort of assert macroses are defined into nothing in
release build, so make sure you don't do anything usefull in assert
expression.
Happy hunting ;)
-- Slava
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users