#40 Change in Conditional::wait() to not recharge timeout

open
nobody
None
5
2012-11-20
2004-10-29
Anonymous
No

From: vlkukushkin@yandex.ru
Subject: change conditional wait to not recharge
timeout - usefull when you wait for item in queue and
check item's context until timeout expired. Also it gives
you real (not user) time. If you set negative timeout,
wait() continues until abstime come.
File: mutex.cpp
Function: Conditional::wait()
------------
[kvd@lib2 kvd]$ diff -
pb /home/kvd/Projects/commoncpp2-
1.2.4/src/mutex.cpp.KUK /home/kvd/Projects/commoncp
p2-1.2.4/src/mutex.cpp
*** /home/kvd/Projects/commoncpp2-
1.2.4/src/mutex.cpp.KUK Fri Oct 29 16:24:31 2004
--- /home/kvd/Projects/commoncpp2-
1.2.4/src/mutex.cpp Thu Jul 22 20:19:19 2004
*************** void Conditional::signal(bool
broadcast)
*** 173,179 ****

bool Conditional::wait(timeout_t timeout, bool locked)
{
! static struct timespec ts;
int rc;

if(!locked)
--- 173,179 ----

bool Conditional::wait(timeout_t timeout, bool locked)
{
! struct timespec ts;
int rc;

if(!locked)
*************** bool Conditional::wait(timeout_t
timeout
*** 185,191 ****
leaveMutex();
return true;
}
- if(timeout > 0)
getTimeout(&ts, timeout);
rc = pthread_cond_timedwait(&_cond, &_mutex,
&ts);
if(!locked)
--- 185,190 ----

Discussion