summaryrefslogtreecommitdiff
path: root/TAO/tao/RTCORBA/RT_Mutex.h
blob: c16cb59a3b7a79ea9e52c0f5b353ffe007a37162 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
/* -*- C++ -*- */
//=============================================================================
/**
 *  @file   RT_Mutex.h
 *
 *  $Id$
 *
 *  @author Frank Hunleth <fhunleth@cs.wustl.edu>
 */
//=============================================================================


#ifndef TAO_RT_MUTEX_H
#define TAO_RT_MUTEX_H

#include "ace/pre.h"
#include "tao/orbconf.h"

#if !defined (ACE_LACKS_PRAGMA_ONCE)
# pragma once
#endif /* ACE_LACKS_PRAGMA_ONCE */

#define TAO_RTCORBA_SAFE_INCLUDE
#include "RTCORBAC.h"
#undef TAO_RTCORBA_SAFE_INCLUDE

#include "tao/LocalObject.h"

#if defined(_MSC_VER)
#if (_MSC_VER >= 1200)
#pragma warning(push)
#endif /* _MSC_VER >= 1200 */
#pragma warning(disable:4250)
#endif /* _MSC_VER */

/**
 * @class TAO_RT_Mutex
 *
 * @brief  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.
 *
 */

class TAO_RTCORBA_Export TAO_RT_Mutex
  : public RTCORBA::Mutex,
    public TAO_Local_RefCounted_Object
{
public:
  /// Constructor.
  TAO_RT_Mutex (void);

  /// Destructor.
  virtual ~TAO_RT_Mutex (void);

  /// Acquire the lock.
  virtual void lock (CORBA::Environment &ACE_TRY_ENV =
                     TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /// Release the lock.
  virtual void unlock (CORBA::Environment &ACE_TRY_ENV =
                       TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /**
   * 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.
   */
  virtual CORBA::Boolean try_lock (TimeBase::TimeT max_wait,
                                   CORBA::Environment &ACE_TRY_ENV =
                                   TAO_default_environment ())
    ACE_THROW_SPEC ((CORBA::SystemException));

  /// Returns the name of the mutex.
  virtual const char *name (void) const;

protected:
  /// Synchronization lock.
  TAO_SYNCH_MUTEX mu_;
};

#if (TAO_HAS_NAMED_RT_MUTEXES == 1)
/**
 * @class TAO_Named_RT_Mutex
 *
 * @brief Extension to TAO_RT_Mutex to support named mutexes.
 *
 */

class TAO_RTCORBA_Export TAO_Named_RT_Mutex : public TAO_RT_Mutex
{
public:
  /// Constructor.
  TAO_Named_RT_Mutex (const char *name);

  /// Returns the name of the mutex.
  virtual const char *name (void) const;

protected:

  /// My name.
  ACE_CString name_;
};
#endif /* TAO_HAS_NAMED_RT_MUTEXES == 1 */

#if defined(_MSC_VER) && (_MSC_VER >= 1200)
#pragma warning(pop)
#endif /* _MSC_VER */

#include "ace/post.h"
#endif /* TAO_RT_MUTEX_H */