diff options
author | Ossama Othman <ossama-othman@users.noreply.github.com> | 2001-01-26 22:33:06 +0000 |
---|---|---|
committer | Ossama Othman <ossama-othman@users.noreply.github.com> | 2001-01-26 22:33:06 +0000 |
commit | f9232701ff492b6d8b5eda8e4bb5c85ea72c5bb0 (patch) | |
tree | eb9ccb6c2eed261b6b2f0ba2e1361fa7f7251c83 /ace/OS.i | |
parent | a4cb385d45f8adb31d23819c5677851e25ad40a9 (diff) | |
download | ATCD-f9232701ff492b6d8b5eda8e4bb5c85ea72c5bb0.tar.gz |
ChangeLogTag:Fri Jan 26 14:13:32 2001 Ossama Othman <ossama@uci.edu>
Diffstat (limited to 'ace/OS.i')
-rw-r--r-- | ace/OS.i | 68 |
1 files changed, 67 insertions, 1 deletions
@@ -1776,7 +1776,7 @@ ACE_OS::mutex_lock (ACE_mutex_t *m) #if defined (ACE_HAS_PACE) int dummy_retval = 0; ACE_OSCALL_RETURN (ACE_ADAPT_RETVAL (::pace_pthread_mutex_lock (m), - dummy_retval), int, -1);; + dummy_retval), int, -1); #elif defined (ACE_HAS_THREADS) # if defined (ACE_HAS_PTHREADS) // Note, don't use "::" here since the following call is often a macro. @@ -2004,6 +2004,72 @@ ACE_OS::mutex_trylock (ACE_mutex_t *m, int &abandoned) } ACE_INLINE int +ACE_OS::mutex_timedlock (ACE_mutex_t *m, + ACE_Time_Value *timeout) +{ +#if defined (ACE_HAS_THREADS) + +# if defined (ACE_HAS_MUTEX_TIMEOUTS) + + int result; + timespec_t ts; + + // "timeout" should be an absolute time. + + if (timeout != 0) + ts = *timeout; // Calls ACE_Time_Value::operator timespec_t(). + + // Note that the mutex should not be a recursive one, i.e., it + // should only be a standard mutex or an error checking mutex. + +# if defined (ACE_HAS_PTHREADS) + + if (timeout == 0) + return ACE_OS::mutex_lock (m); // Block indefinitely + else + { + ACE_OSCALL (ACE_ADAPT_RETVAL ( + ::pthread_mutex_timedlock (m, &ts), + result), int, -1, result); + } +# else /* ACE_HAS_PTHREADS */ + + // @@ Apparently only POSIX threads have the timed lock + // functionality. + + if (timeout == 0) + return ACE_OS::mutex_lock (m); // Block indefinitely. + else + return ACE_OS::mutex_trylock (m); // The best that we can do is + // try to grab the lock. + +# endif /* ACE_HAS_PTHREADS */ + + if (timeout != 0) + timeout->set (ts); // Update the time value before returning. + + return result; + +# else /* ACE_HAS_MUTEX_TIMEOUTS */ + + if (timeout == 0) + return ACE_OS::mutex_lock (m); // Block indefinitely. + else + return ACE_OS::mutex_trylock (m); // The best that we can do is + // try to grab the lock. + +# endif /* ACE_HAS_MUTEX_TIMEOUTS */ + +#else /* ACE_HAS_THREADS */ + + ACE_UNUSED_ARG (m); + ACE_UNUSED_ARG (timeout); + ACE_NOTSUP_RETURN (-1); + +#endif /* ACE_HAS_THREADS */ +} + +ACE_INLINE int ACE_OS::mutex_unlock (ACE_mutex_t *m) { ACE_OS_TRACE ("ACE_OS::mutex_unlock"); |