summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/Trader/Monitor.h
blob: 4fa35a45d6ae2dac63614c03d95346c2005075c2 (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
/* -*- C++ -*- */

// ============================================================================
// $Id$
//
// = LIBRARY
//    orsvcs
// 
// = FILENAME
//    Monitor.h
//
// = AUTHOR
//    Irfan Pyarali <irfan@cs.wustl.edu>
//   
// ============================================================================

#ifndef TAO_MONITOR_H
#define TAO_MONITOR_H

template <class TYPE, class TAO_LOCK>
class TAO_Monitor : public TYPE
{
  //
  // = TITLE
  //
  //     A utility class for writing applications where access to an
  //     object must be synchronized in a multithreaded environment.
  //     
  //
  // = DESCRIPTION
  //
  //     A monitor associates a lock of type TAO_LOCK with an object
  //     of type TYPE.  The user is fully responsible for invoking all
  //     necessary acquire/release operations on that lock (i.e. the
  //     monitor does not automate any lock operations - all
  //     operations are invoked explicitly by the user).  The
  //     usefullness of a monitor is in associating one lock with one
  //     object without the need for inheritance or much code.
  //  
  //
public:
  
  typedef TAO_LOCK LOCK_TYPE;
  
  // Return a reference to the lock that I use.
  TAO_LOCK &lock (void)
  {
    return this->lock_;
  }

  // Return a reference to the lock that I use.
  const TAO_LOCK &lock (void) const
  {
    return this->lock_;
  }

protected:

  TAO_LOCK lock_;
  // Lock used to monitor the object.
};

#endif /* #define TAO_MONITOR_H */