summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ChangeLog33
-rw-r--r--ChangeLogs/ChangeLog-02a33
-rw-r--r--ChangeLogs/ChangeLog-03a33
-rw-r--r--TAO/ChangeLogs/ChangeLog-02a7
-rw-r--r--TAO/tao/RTCORBA/RT_Mutex.cpp19
-rw-r--r--THANKS1
-rw-r--r--ace/Message_Queue_T.cpp21
-rw-r--r--ace/OS.h31
-rw-r--r--ace/OS.i35
-rw-r--r--ace/Svc_Conf_Tokens.h1
-rw-r--r--ace/Synch.h121
-rw-r--r--ace/Synch.i41
-rw-r--r--tests/Thread_Mutex_Test.cpp10
13 files changed, 324 insertions, 62 deletions
diff --git a/ChangeLog b/ChangeLog
index aebcee4027e..84f213d71ce 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,36 @@
+Mon Jul 30 05:43:23 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * ace/Synch.h (ACE_Semaphore): Corrected the comment on
+ how to get POSIX Pthreads "implementation" of semaphores (which
+ supports the timed acquire() option). Thanks to Grzegorz
+ Sikora <GSikora1@era.pl> for reporting this.
+
+Sun Jul 29 19:03:56 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * tests/Thread_Mutex_Test.cpp (test): Fixed this test to be
+ consistent wrt the errno for the timed acquire(), which should
+ now always be set to ETIME rather than ETIMEDOUT and EBUSY.
+
+ * ace/Message_Queue_T.cpp (wait_not_full_cond,
+ wait_not_empty_cond): Fixed a nasty bug with the semaphore
+ version of ACE_Message_Queue that would have reared it's ugly
+ head if ACE_NULL_SYNCH were used when
+ ACE_HAS_OPTIMIZED_MESSAGE_QUEUE was enabled. Fixing this bug
+ also triggered the following changes.
+
+ * ace/OS.{h,i}: Added support for ACE_OS::sema_wait(),
+ ACE_OS::mutex_lock(), ACE_OS::thread_mutex_lock() that take
+ ACE_Time_Value *.
+
+ * ace/OS.i: For some odd reason the timeouts for the timed version
+ of mutex_lock() were returning a random smattering of errnos.
+ I've changed them to all be consistent with the
+ ACE_Condition_Thread_Mutex::wait() errno, which is ETIME.
+
+ * ace/Synch.h: Updated the documentation of all the timed
+ acquire() methods to explain what the various return values
+ mean.
+
Sun Jul 29 22:10:40 2001 Ossama Othman <ossama@uci.edu>
* tests/Service_Config_DLL.cpp:
diff --git a/ChangeLogs/ChangeLog-02a b/ChangeLogs/ChangeLog-02a
index aebcee4027e..84f213d71ce 100644
--- a/ChangeLogs/ChangeLog-02a
+++ b/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,36 @@
+Mon Jul 30 05:43:23 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * ace/Synch.h (ACE_Semaphore): Corrected the comment on
+ how to get POSIX Pthreads "implementation" of semaphores (which
+ supports the timed acquire() option). Thanks to Grzegorz
+ Sikora <GSikora1@era.pl> for reporting this.
+
+Sun Jul 29 19:03:56 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * tests/Thread_Mutex_Test.cpp (test): Fixed this test to be
+ consistent wrt the errno for the timed acquire(), which should
+ now always be set to ETIME rather than ETIMEDOUT and EBUSY.
+
+ * ace/Message_Queue_T.cpp (wait_not_full_cond,
+ wait_not_empty_cond): Fixed a nasty bug with the semaphore
+ version of ACE_Message_Queue that would have reared it's ugly
+ head if ACE_NULL_SYNCH were used when
+ ACE_HAS_OPTIMIZED_MESSAGE_QUEUE was enabled. Fixing this bug
+ also triggered the following changes.
+
+ * ace/OS.{h,i}: Added support for ACE_OS::sema_wait(),
+ ACE_OS::mutex_lock(), ACE_OS::thread_mutex_lock() that take
+ ACE_Time_Value *.
+
+ * ace/OS.i: For some odd reason the timeouts for the timed version
+ of mutex_lock() were returning a random smattering of errnos.
+ I've changed them to all be consistent with the
+ ACE_Condition_Thread_Mutex::wait() errno, which is ETIME.
+
+ * ace/Synch.h: Updated the documentation of all the timed
+ acquire() methods to explain what the various return values
+ mean.
+
Sun Jul 29 22:10:40 2001 Ossama Othman <ossama@uci.edu>
* tests/Service_Config_DLL.cpp:
diff --git a/ChangeLogs/ChangeLog-03a b/ChangeLogs/ChangeLog-03a
index aebcee4027e..84f213d71ce 100644
--- a/ChangeLogs/ChangeLog-03a
+++ b/ChangeLogs/ChangeLog-03a
@@ -1,3 +1,36 @@
+Mon Jul 30 05:43:23 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * ace/Synch.h (ACE_Semaphore): Corrected the comment on
+ how to get POSIX Pthreads "implementation" of semaphores (which
+ supports the timed acquire() option). Thanks to Grzegorz
+ Sikora <GSikora1@era.pl> for reporting this.
+
+Sun Jul 29 19:03:56 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * tests/Thread_Mutex_Test.cpp (test): Fixed this test to be
+ consistent wrt the errno for the timed acquire(), which should
+ now always be set to ETIME rather than ETIMEDOUT and EBUSY.
+
+ * ace/Message_Queue_T.cpp (wait_not_full_cond,
+ wait_not_empty_cond): Fixed a nasty bug with the semaphore
+ version of ACE_Message_Queue that would have reared it's ugly
+ head if ACE_NULL_SYNCH were used when
+ ACE_HAS_OPTIMIZED_MESSAGE_QUEUE was enabled. Fixing this bug
+ also triggered the following changes.
+
+ * ace/OS.{h,i}: Added support for ACE_OS::sema_wait(),
+ ACE_OS::mutex_lock(), ACE_OS::thread_mutex_lock() that take
+ ACE_Time_Value *.
+
+ * ace/OS.i: For some odd reason the timeouts for the timed version
+ of mutex_lock() were returning a random smattering of errnos.
+ I've changed them to all be consistent with the
+ ACE_Condition_Thread_Mutex::wait() errno, which is ETIME.
+
+ * ace/Synch.h: Updated the documentation of all the timed
+ acquire() methods to explain what the various return values
+ mean.
+
Sun Jul 29 22:10:40 2001 Ossama Othman <ossama@uci.edu>
* tests/Service_Config_DLL.cpp:
diff --git a/TAO/ChangeLogs/ChangeLog-02a b/TAO/ChangeLogs/ChangeLog-02a
index 19c6b30ba63..216014a5b11 100644
--- a/TAO/ChangeLogs/ChangeLog-02a
+++ b/TAO/ChangeLogs/ChangeLog-02a
@@ -1,3 +1,10 @@
+Sun Jul 29 19:31:34 2001 Douglas C. Schmidt <schmidt@tango.doc.wustl.edu>
+
+ * tao/RTCORBA/RT_Mutex.cpp (try_lock): Since we fixed the timed
+ ACE_OS::mutex_lock() to set errno to ETIME we can cleanup the
+ code here to remove the checks for errno == EBUSY and errno ==
+ ETIMEDOUT.
+
Sun Jul 29 20:00:00 2001 Craig Rodrigues <crodrigu@bbn.com>
* tao/PortableServer/ORB_Manager.h:
diff --git a/TAO/tao/RTCORBA/RT_Mutex.cpp b/TAO/tao/RTCORBA/RT_Mutex.cpp
index 94bec75f82e..c35317aade1 100644
--- a/TAO/tao/RTCORBA/RT_Mutex.cpp
+++ b/TAO/tao/RTCORBA/RT_Mutex.cpp
@@ -36,10 +36,8 @@ TAO_RT_Mutex::try_lock (TimeBase::TimeT wait_time,
int result;
if (wait_time == 0)
- {
- // No wait.
- result = this->mu_.tryacquire ();
- }
+ // No wait.
+ result = this->mu_.tryacquire ();
else
{
// Wait for the specified amount of time before giving up.
@@ -57,18 +55,13 @@ TAO_RT_Mutex::try_lock (TimeBase::TimeT wait_time,
result = this->mu_.acquire (absolute_time);
}
- // Check result.
- if (result == 0 )
+ if (result == 0)
return 1;
- else
- if (result == -1
- && (errno == EBUSY || errno == ETIMEDOUT))
+ else if (result == -1 && errno == ETIME)
return 0;
else
- {
- // Some really bad error.
- ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
- }
+ // Some really bad error.
+ ACE_THROW_RETURN (CORBA::INTERNAL (), 0);
}
const char *
diff --git a/THANKS b/THANKS
index 5ad333ff0b8..efb0f46568a 100644
--- a/THANKS
+++ b/THANKS
@@ -1300,6 +1300,7 @@ Egon Wuchner <Egon.Wuchner@mchp.siemens.de>
Ugendreshwar Kudupudi <ugenderk@rediffmail.com>
Ekkehard Hoffmann <ehoffman@fzi.de>
Ted Krovetz <ted@digitalfountain.com>
+Grzegorz Sikora <GSikora1@era.pl>
I would particularly like to thank Paul Stephenson, who worked with me
at Ericsson in the early 1990's. Paul devised the recursive Makefile
diff --git a/ace/Message_Queue_T.cpp b/ace/Message_Queue_T.cpp
index 8bf5cafe814..1dfba2d3ef2 100644
--- a/ace/Message_Queue_T.cpp
+++ b/ace/Message_Queue_T.cpp
@@ -712,10 +712,10 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_full_cond (ACE_Guard<ACE_SYNCH_MUTEX_
++this->enqueue_waiters_;
// @@ Need to add sanity checks for failure...
mon.release ();
- if (timeout == 0)
- result = this->not_full_cond_.acquire ();
- else
- result = this->not_full_cond_.acquire (*timeout);
+ result = this->not_full_cond_.acquire (timeout);
+
+ if (result == -1 && errno == ETIME)
+ errno = EWOULDBLOCK;
// Save/restore errno.
ACE_Errno_Guard error (errno);
@@ -757,14 +757,11 @@ ACE_Message_Queue<ACE_SYNCH_USE>::wait_not_empty_cond (ACE_Guard<ACE_SYNCH_MUTEX
++this->dequeue_waiters_;
// @@ Need to add sanity checks for failure...
mon.release ();
- if (timeout == 0)
- result = this->not_empty_cond_.acquire ();
- else
- {
- result = this->not_empty_cond_.acquire (*timeout);
- if (result == -1 && errno == ETIME)
- errno = EWOULDBLOCK;
- }
+ result = this->not_empty_cond_.acquire (timeout);
+
+ if (result == -1 && errno == ETIME)
+ errno = EWOULDBLOCK;
+
// Save/restore errno.
ACE_Errno_Guard error (errno);
mon.acquire ();
diff --git a/ace/OS.h b/ace/OS.h
index caf3ccfdd15..c9f95298da7 100644
--- a/ace/OS.h
+++ b/ace/OS.h
@@ -5933,19 +5933,30 @@ public:
static int mutex_lock (ACE_mutex_t *m,
int &abandoned);
- /// This method attempts to acquire a lock, but gives up if the lock
- /// has not been acquired by the given time.
/**
- * If the lock is not acquired within the given amount of time, then
- * this method returns with an ETIMEDOUT errno on platforms that
- * actually support timed mutexes. The timeout should be an
- * absolute time. Note that the mutex should not be a recursive
- * one, i.e., it should only be a standard mutex or an error
- * checking mutex.
+ * This method attempts to acquire a lock, but gives up if the lock
+ * has not been acquired by the given time. If the lock is not
+ * acquired within the given amount of time, then this method
+ * returns -1 with an <ETIME> errno on platforms that actually
+ * support timed mutexes. The timeout should be an absolute time.
+ * Note that the mutex should not be a recursive one, i.e., it
+ * should only be a standard mutex or an error checking mutex.
*/
static int mutex_lock (ACE_mutex_t *m,
const ACE_Time_Value &timeout);
+ /**
+ * If <timeout> == 0, calls <ACE_OS::mutex_lock(m)>. Otherwise,
+ * this method attempts to acquire a lock, but gives up if the lock
+ * has not been acquired by the given time, in which case it returns
+ * -1 with an <ETIME> errno on platforms that actually support timed
+ * mutexes. The timeout should be an absolute time. Note that the
+ * mutex should not be a recursive one, i.e., it should only be a
+ * standard mutex or an error checking mutex.
+ */
+ static int mutex_lock (ACE_mutex_t *m,
+ const ACE_Time_Value *timeout);
+
/// Win32 note: Abandoned mutexes are not treated differently. 0 is
/// returned since the calling thread does get the ownership.
static int mutex_trylock (ACE_mutex_t *m);
@@ -5973,6 +5984,8 @@ public:
static int thread_mutex_lock (ACE_thread_mutex_t *m);
static int thread_mutex_lock (ACE_thread_mutex_t *m,
const ACE_Time_Value &timeout);
+ static int thread_mutex_lock (ACE_thread_mutex_t *m,
+ const ACE_Time_Value *timeout);
static int thread_mutex_trylock (ACE_thread_mutex_t *m);
static int thread_mutex_unlock (ACE_thread_mutex_t *m);
//@}
@@ -6272,6 +6285,8 @@ public:
static int sema_wait (ACE_sema_t *s);
static int sema_wait (ACE_sema_t *s,
ACE_Time_Value &tv);
+ static int sema_wait (ACE_sema_t *s,
+ ACE_Time_Value *tv);
//@}
//@{ @name A set of wrappers for System V semaphores.
diff --git a/ace/OS.i b/ace/OS.i
index c85705ee137..7135ad8ba7e 100644
--- a/ace/OS.i
+++ b/ace/OS.i
@@ -2043,8 +2043,13 @@ ACE_OS::mutex_lock (ACE_mutex_t *m,
// Note that the mutex should not be a recursive one, i.e., it
// should only be a standard mutex or an error checking mutex.
- ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts),
+ ACE_OSCALL (ACE_ADAPT_RETVAL (::pthread_mutex_timedlock (m, &ts),
result), int, -1);
+
+ // We need to adjust this to make the errno values consistent.
+ if (result == -1 && errno == ETIMEDOUT)
+ errno = ETIME;
+ return result;
# elif defined (ACE_HAS_WTHREADS)
// Note that we must convert between absolute time (which is passed
// as a parameter) and relative time (which is what the system call
@@ -2063,7 +2068,7 @@ ACE_OS::mutex_lock (ACE_mutex_t *m,
// Note that we still hold the lock
return 0;
case WAIT_TIMEOUT:
- errno = EBUSY;
+ errno = ETIME;
return -1;
default:
// This is a hack, we need to find an appropriate mapping...
@@ -2088,8 +2093,8 @@ ACE_OS::mutex_lock (ACE_mutex_t *m,
u_long ticks = relative_time.sec() * KC_TICKS2SEC +
relative_time.usec () * KC_TICKS2SEC /
ACE_ONE_SECOND_IN_USECS;
- if(ticks == 0)
- ACE_OSCALL_RETURN (::sm_p (*m, SM_NOWAIT, 0), int, -1); //no timeout
+ if (ticks == 0)
+ ACE_OSCALL_RETURN (::sm_p (*m, SM_NOWAIT, 0), int, -1); // no timeout
else
ACE_OSCALL_RETURN (::sm_p (*m, SM_WAIT, ticks), int, -1);
@@ -2126,6 +2131,13 @@ ACE_OS::mutex_lock (ACE_mutex_t *m,
}
ACE_INLINE int
+ACE_OS::mutex_lock (ACE_mutex_t *m,
+ const ACE_Time_Value *timeout)
+{
+ return timeout == 0 ? ACE_OS::mutex_lock (m) : ACE_OS::mutex_lock (m, *timeout);
+}
+
+ACE_INLINE int
ACE_OS::mutex_unlock (ACE_mutex_t *m)
{
ACE_OS_TRACE ("ACE_OS::mutex_unlock");
@@ -2318,6 +2330,15 @@ ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m,
}
ACE_INLINE int
+ACE_OS::thread_mutex_lock (ACE_thread_mutex_t *m,
+ const ACE_Time_Value *timeout)
+{
+ return timeout == 0
+ ? ACE_OS::thread_mutex_lock (m)
+ : ACE_OS::thread_mutex_lock (m, *timeout);
+}
+
+ACE_INLINE int
ACE_OS::thread_mutex_trylock (ACE_thread_mutex_t *m)
{
ACE_OS_TRACE ("ACE_OS::thread_mutex_trylock");
@@ -4259,6 +4280,12 @@ ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value &tv)
}
ACE_INLINE int
+ACE_OS::sema_wait (ACE_sema_t *s, ACE_Time_Value *tv)
+{
+ return tv == 0 ? ACE_OS::sema_wait (s) : ACE_OS::sema_wait (s, *tv);
+}
+
+ACE_INLINE int
ACE_OS::rw_tryrdlock (ACE_rwlock_t *rw)
{
ACE_OS_TRACE ("ACE_OS::rw_tryrdlock");
diff --git a/ace/Svc_Conf_Tokens.h b/ace/Svc_Conf_Tokens.h
index 7287aef02c2..42bfbf369b3 100644
--- a/ace/Svc_Conf_Tokens.h
+++ b/ace/Svc_Conf_Tokens.h
@@ -1,5 +1,4 @@
// $Id$
-
#define ACE_DYNAMIC 257
#define ACE_STATIC 258
#define ACE_SUSPEND 259
diff --git a/ace/Synch.h b/ace/Synch.h
index b6906a4b987..e6b8d491d85 100644
--- a/ace/Synch.h
+++ b/ace/Synch.h
@@ -188,21 +188,37 @@ public:
int acquire (void);
/**
- * Block the thread until <tv> times out or until the semaphore
- * count becomes greater than 0 (at which point it is decremented).
- * Note that <tv> is assumed to be in "absolute" rather than
- * "relative" time. The value of <tv> is updated upon return to
- * show the actual (absolute) acquisition time.
+ * Block the thread until the semaphore count becomes greater than 0
+ * (at which point it is decremented) or until <tv> times out (in
+ * which case -1 is returned and <errno> == <ETIME>). Note that <tv>
+ * is assumed to be in "absolute" rather than "relative" time. The
+ * value of <tv> is updated upon return to show the actual
+ * (absolute) acquisition time.
*
* NOTE: Solaris threads do not support timed semaphores.
* Therefore, if you're running on Solaris you might want to
* consider using the ACE POSIX pthreads implementation instead,
* which can be enabled by compiling ACE with
- * -D_POSIX_PTHREAD_SEMANTICS.
- */
+ * -DACE_HAS_PTHREADS rather than -DACE_HAS_STHREADS. */
int acquire (ACE_Time_Value &tv);
/**
+ * If <tv> == 0 then call <acquire()> directly. Otherwise, Block
+ * the thread until the semaphore count becomes greater than 0
+ * (at which point it is decremented) or until <tv> times out (in
+ * which case -1 is returned and <errno> == <ETIME>). Note that
+ * <*tv> is assumed to be in "absolute" rather than "relative" time.
+ * The value of <*tv> is updated upon return to show the actual
+ * (absolute) acquisition time.
+ *
+ * NOTE: Solaris threads do not support timed semaphores.
+ * Therefore, if you're running on Solaris you might want to
+ * consider using the ACE POSIX pthreads implementation instead,
+ * which can be enabled by compiling ACE with
+ * -DACE_HAS_PTHREADS rather than -DACE_HAS_STHREADS. */
+ int acquire (ACE_Time_Value *tv);
+
+ /**
* Conditionally decrement the semaphore if count is greater than 0
* (i.e., won't block). Returns -1 on failure. If we "failed"
* because someone else already had the lock, <errno> is set to
@@ -298,17 +314,40 @@ public:
void * = 0,
int max = 0x7fffffff);
~ACE_Null_Semaphore (void);
+ /// Return 0.
int remove (void);
- int acquire (ACE_Time_Value &);
+ /// Return 0.
int acquire (void);
+
+ /// Return -1 with <errno> == <ETIME>.
+ int acquire (ACE_Time_Value &);
+
+ /// Return -1 with <errno> == <ETIME>.
+ int acquire (ACE_Time_Value *);
+
+ /// Return 0.
int tryacquire (void);
+
+ /// Return 0.
int release (void);
+
+ /// Return 0.
int release (size_t);
+
+ /// Return 0.
int acquire_write (void);
+
+ /// Return 0.
int tryacquire_write (void);
+
+ /// Return 0.
int tryacquire_write_upgrade (void);
+
+ /// Return 0.
int acquire_read (void);
+
+ /// Return 0.
int tryacquire_read (void);
/// Dump the state of an object.
@@ -444,14 +483,24 @@ public:
int acquire (void);
/**
- * Block the thread until <tv> times out. Note that <tv> is assumed
- * to be in "absolute" rather than "relative" time. The value of
- * <tv> is updated upon return to show the actual (absolute)
- * acquisition time.
+ * Block the thread until the mutex is acquired or <tv> times out,
+ * in which case -1 is returned and <errno> == <ETIME>. Note that
+ * <tv> is assumed to be in "absolute" rather than "relative" time.
+ * The value of <tv> is updated upon return to show the actual
+ * (absolute) acquisition time.
*/
int acquire (ACE_Time_Value &tv);
/**
+ * If <tv> == 0 then call <acquire()> directly. Otherwise, block
+ * the thread until the mutex is acquired or <tv> times out, in
+ * which case -1 is returned and <errno> == <ETIME>. Note that
+ * <*tv> is assumed to be in "absolute" rather than "relative" time.
+ * The value of <*tv> is updated upon return to show the actual
+ * (absolute) acquisition time. */
+ int acquire (ACE_Time_Value *tv);
+
+ /**
* Conditionally acquire lock (i.e., don't wait on queue). Returns
* -1 on failure. If we "failed" because someone else already had
* the lock, <errno> is set to <EBUSY>.
@@ -582,16 +631,37 @@ class ACE_Export ACE_Null_Mutex
public:
ACE_Null_Mutex (const ACE_TCHAR * = 0);
~ACE_Null_Mutex (void);
+ /// Return 0.
int remove (void);
+ /// Return 0.
int acquire (void);
+
+ /// Return -1 with <errno> == <ETIME>.
int acquire (ACE_Time_Value &timeout);
+
+ /// Return -1 with <errno> == <ETIME>.
+ int acquire (ACE_Time_Value *timeout);
+
+ /// Return 0.
int tryacquire (void);
+
+ /// Return 0.
int release (void);
+
+ /// Return 0.
int acquire_write (void);
+
+ /// Return 0.
int tryacquire_write (void);
+
+ /// Return 0.
int tryacquire_write_upgrade (void);
+
+ /// Return 0.
int acquire_read (void);
+
+ /// Return 0.
int tryacquire_read (void);
/// Dump the state of an object.
@@ -627,9 +697,17 @@ public:
const ACE_TCHAR * = 0,
void * = 0);
~ACE_Null_Condition (void);
+
+ /// Returns 0.
int remove (void);
+
+ /// Returns -1 with <errno> == <ETIME>.
int wait (ACE_Time_Value * = 0);
+
+ /// Returns 0.
int signal (void);
+
+ /// Returns 0.
int broadcast (void);
ACE_Null_Mutex &mutex (void);
@@ -941,14 +1019,25 @@ public:
int acquire (void);
/**
- * Block the thread until <tv> times out. Note that <tv> is assumed
- * to be in "absolute" rather than "relative" time. The value of
- * <tv> is updated upon return to show the actual (absolute)
- * acquisition time.
+ * Block the thread until we acquire the mutex or until <tv> times
+ * out, in which case -1 is returned with <errno> == <ETIME>. Note
+ * that <tv> is assumed to be in "absolute" rather than "relative"
+ * time. The value of <tv> is updated upon return to show the
+ * actual (absolute) acquisition time.
*/
int acquire (ACE_Time_Value &tv);
/**
+ * If <tv> == 0 the call <acquire()> directly. Otherwise, Block the
+ * thread until we acquire the mutex or until <tv> times out, in
+ * which case -1 is returned with <errno> == <ETIME>. Note that
+ * <*tv> is assumed to be in "absolute" rather than "relative" time.
+ * The value of <*tv> is updated upon return to show the actual
+ * (absolute) acquisition time.
+ */
+ int acquire (ACE_Time_Value *tv);
+
+ /**
* Conditionally acquire lock (i.e., don't wait on queue). Returns
* -1 on failure. If we "failed" because someone else already had
* the lock, <errno> is set to <EBUSY>.
diff --git a/ace/Synch.i b/ace/Synch.i
index 645daf57514..4d6550a6e8d 100644
--- a/ace/Synch.i
+++ b/ace/Synch.i
@@ -172,6 +172,13 @@ ACE_Mutex::acquire (ACE_Time_Value &tv)
}
ACE_INLINE int
+ACE_Mutex::acquire (ACE_Time_Value *tv)
+{
+ // ACE_TRACE ("ACE_Mutex::acquire");
+ return ACE_OS::mutex_lock (&this->lock_, tv);
+}
+
+ACE_INLINE int
ACE_Mutex::tryacquire (void)
{
// ACE_TRACE ("ACE_Mutex::tryacquire");
@@ -277,6 +284,13 @@ ACE_Semaphore::acquire (ACE_Time_Value &tv)
}
ACE_INLINE int
+ACE_Semaphore::acquire (ACE_Time_Value *tv)
+{
+// ACE_TRACE ("ACE_Semaphore::acquire");
+ return ACE_OS::sema_wait (&this->semaphore_, tv);
+}
+
+ACE_INLINE int
ACE_Semaphore::tryacquire (void)
{
// ACE_TRACE ("ACE_Semaphore::tryacquire");
@@ -372,7 +386,15 @@ ACE_Null_Semaphore::remove (void)
ACE_INLINE int
ACE_Null_Semaphore::acquire (ACE_Time_Value &)
{
- return 0;
+ errno = ETIME;
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Null_Semaphore::acquire (ACE_Time_Value *)
+{
+ errno = ETIME;
+ return -1;
}
ACE_INLINE int
@@ -493,6 +515,13 @@ ACE_Thread_Mutex::acquire (ACE_Time_Value &tv)
}
ACE_INLINE int
+ACE_Thread_Mutex::acquire (ACE_Time_Value *tv)
+{
+ // ACE_TRACE ("ACE_Thread_Mutex::acquire");
+ return ACE_OS::thread_mutex_lock (&this->lock_, tv);
+}
+
+ACE_INLINE int
ACE_Thread_Mutex::tryacquire (void)
{
// ACE_TRACE ("ACE_Thread_Mutex::tryacquire");
@@ -731,7 +760,15 @@ ACE_Null_Mutex::acquire (void)
ACE_INLINE int
ACE_Null_Mutex::acquire (ACE_Time_Value &)
{
- return 0;
+ errno = ETIME;
+ return -1;
+}
+
+ACE_INLINE int
+ACE_Null_Mutex::acquire (ACE_Time_Value *)
+{
+ errno = ETIME;
+ return -1;
}
ACE_INLINE int
diff --git a/tests/Thread_Mutex_Test.cpp b/tests/Thread_Mutex_Test.cpp
index e68d16ff1e5..8608833745f 100644
--- a/tests/Thread_Mutex_Test.cpp
+++ b/tests/Thread_Mutex_Test.cpp
@@ -64,12 +64,10 @@ test (void *args)
if (mutex->acquire (timeout) != 0)
{
- if (errno == ETIMEDOUT || errno == EBUSY)
- {
- ACE_DEBUG ((LM_DEBUG,
- ACE_TEXT ("(%P|%t) = mutex acquisition ")
- ACE_TEXT ("timed out\n")));
- }
+ if (errno == ETIME)
+ ACE_DEBUG ((LM_DEBUG,
+ ACE_TEXT ("(%P|%t) = mutex acquisition ")
+ ACE_TEXT ("timed out\n")));
else if (errno == ENOTSUP)
{
#if !defined (ACE_HAS_MUTEX_TIMEOUTS)