TAO_RT_Mutex Class Reference

Abstract base class for the TAO RT Mutex implementations. More...

#include <RT_Mutex.h>

Inheritance diagram for TAO_RT_Mutex:

Inheritance graph
[legend]
Collaboration diagram for TAO_RT_Mutex:

Collaboration graph
[legend]
List of all members.

Public Member Functions

virtual void lock (void)
 Acquire the lock.
virtual void unlock (void)
 Release the lock.
virtual CORBA::Boolean try_lock (TimeBase::TimeT max_wait)
virtual const char * name (void) const
 Returns the name of the mutex.

Protected Member Functions

virtual ~TAO_RT_Mutex (void)
 Destructor.

Protected Attributes

TAO_SYNCH_MUTEX mu_
 Synchronization lock.

Detailed Description

Abstract base class for the TAO RT Mutex implementations.

This class just serves as a base class for any of the TAO RT Mutex implementations. Instances of these classes should be created using the RTCORBA::create_mutex() method.

Definition at line 51 of file RT_Mutex.h.


Constructor & Destructor Documentation

TAO_BEGIN_VERSIONED_NAMESPACE_DECL TAO_RT_Mutex::~TAO_RT_Mutex ( void   )  [protected, virtual]

Destructor.

Definition at line 16 of file RT_Mutex.cpp.

00017 {
00018 }


Member Function Documentation

void TAO_RT_Mutex::lock ( void   )  [virtual]

Acquire the lock.

Definition at line 21 of file RT_Mutex.cpp.

00022 {
00023   if (this->mu_.acquire () != 0)
00024     throw ::CORBA::INTERNAL ();
00025 }

const char * TAO_RT_Mutex::name ( void   )  const [virtual]

Returns the name of the mutex.

Definition at line 71 of file RT_Mutex.cpp.

00072 {
00073   return 0;
00074 }

CORBA::Boolean TAO_RT_Mutex::try_lock ( TimeBase::TimeT  max_wait  )  [virtual]

Acquire the lock, but only wait up to max_wait time. Note that this operation may not be available on all OS platforms, so if you're interested in writing maximally portable programs avoid using this operation in your program designs.

Definition at line 35 of file RT_Mutex.cpp.

References EBUSY, ACE_OS::gettimeofday(), and mu_.

00036 {
00037   int result;
00038 
00039   if (wait_time == 0)
00040     // No wait.
00041     result = this->mu_.tryacquire ();
00042   else
00043     {
00044       // Wait for the specified amount of time before giving up.
00045       // (wait_time units are 100ns.  See TimeBase.pidl)
00046       TimeBase::TimeT seconds = wait_time / 10000000u;
00047       TimeBase::TimeT microseconds = (wait_time % 10000000u) / 10;
00048 
00049       ACE_Time_Value relative_time (ACE_U64_TO_U32 (seconds),
00050                                     ACE_U64_TO_U32 (microseconds));
00051 
00052       ACE_Time_Value absolute_time =
00053         relative_time +
00054         ACE_OS::gettimeofday ();
00055 
00056       result = this->mu_.acquire (absolute_time);
00057     }
00058 
00059   if (result == 0)
00060     return 1;
00061   else if (result == -1 &&
00062            (errno == ETIME ||
00063             errno == EBUSY))
00064     return 0;
00065   else
00066     // Some really bad error.
00067     throw ::CORBA::INTERNAL ();
00068 }

void TAO_RT_Mutex::unlock ( void   )  [virtual]

Release the lock.

Definition at line 28 of file RT_Mutex.cpp.

00029 {
00030   if (this->mu_.release () != 0)
00031     throw ::CORBA::INTERNAL ();
00032 }


Member Data Documentation

TAO_SYNCH_MUTEX TAO_RT_Mutex::mu_ [protected]

Synchronization lock.

Definition at line 82 of file RT_Mutex.h.

Referenced by try_lock().


The documentation for this class was generated from the following files:
Generated on Tue Feb 2 17:42:59 2010 for TAO_RTCORBA by  doxygen 1.4.7