1 #include "tao/RTCORBA/RT_Mutex.h"
3 #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0
5 #include "tao/RTCORBA/RT_ORB.h"
6 #include "tao/SystemException.h"
7 #include "ace/OS_NS_sys_time.h"
9 TAO_BEGIN_VERSIONED_NAMESPACE_DECL
11 TAO_RT_Mutex::~TAO_RT_Mutex ()
18 if (this->mu_
.acquire () != 0)
19 throw ::CORBA::INTERNAL ();
23 TAO_RT_Mutex::unlock ()
25 if (this->mu_
.release () != 0)
26 throw ::CORBA::INTERNAL ();
30 TAO_RT_Mutex::try_lock (TimeBase::TimeT wait_time
)
36 result
= this->mu_
.tryacquire ();
39 // Wait for the specified amount of time before giving up.
40 // (wait_time units are 100ns. See TimeBase.pidl)
41 TimeBase::TimeT seconds
= wait_time
/ 10000000u;
42 TimeBase::TimeT microseconds
= (wait_time
% 10000000u) / 10;
44 ACE_Time_Value
relative_time (ACE_U64_TO_U32 (seconds
),
45 ACE_U64_TO_U32 (microseconds
));
47 ACE_Time_Value absolute_time
=
49 ACE_OS::gettimeofday ();
51 result
= this->mu_
.acquire (absolute_time
);
56 else if (result
== -1 &&
61 // Some really bad error.
62 throw ::CORBA::INTERNAL ();
66 TAO_RT_Mutex::name () const
71 ///////////////////////////////////////////////////////////////////////////////
72 #if (TAO_HAS_NAMED_RT_MUTEXES == 1)
73 TAO_Named_RT_Mutex::TAO_Named_RT_Mutex (const char *name
)
79 TAO_Named_RT_Mutex::name () const
81 return this->name_
.c_str ();
83 #endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */
85 ///////////////////////////////////////////////////////////////////////////////
87 TAO_END_VERSIONED_NAMESPACE_DECL
89 #endif /* TAO_HAS_CORBA_MESSAGING && TAO_HAS_CORBA_MESSAGING != 0 */