summaryrefslogtreecommitdiff
path: root/TAO/orbsvcs/orbsvcs/ESF/ESF_Busy_Lock.h
blob: 5b194529aebf22f1a754b3a06afdf824f26db280 (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
/* -*- C++ -*- */
/**
 *  @file   ESF_Busy_Lock.h
 *
 *  @author Carlos O'Ryan (coryan@cs.wustl.edu)
 *
 *  http://doc.ece.uci.edu/~coryan/EC/index.html
 */

#ifndef TAO_ESF_BUSY_LOCK_H
#define TAO_ESF_BUSY_LOCK_H

#include "ace/config-all.h"

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

#include /**/ "tao/Versioned_Namespace.h"

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

/// Adapt classes that implement the "busy lock" protocol, to conform
/// to the ACE Lock interface.
/**
 * The ACE Lock interface allows us to use any mutex-like object with
 * the ACE synchronization components (such as guards, Lock_Adapter,
 * etc.).
 * One of the synchronization protocols used in the event services
 * uses the following protocol:
 * <UL>
 * <LI> To acquire the lock the @c busy method of the object is invoked.
 * <LI> To release the lock the @c idle method of the object is invoked.
 * <LI> Any changes performed while the lock is held are delayed until
 *      all the locks are released, i.e. the last call to @c idle
 *      executes the changes.
 * </UL>
 */
template<class Adaptee>
class TAO_ESF_Busy_Lock_Adapter
{
public:
  /// Constructor
  TAO_ESF_Busy_Lock_Adapter (Adaptee* adaptee);

  /**
   * @name The ACE_Lock methods
   *
   * Check the documentation in ace/Synch.h for details.
   */
  //@{
  int remove ();
  int acquire ();
  int tryacquire ();
  int release ();
  int acquire_read ();
  int acquire_write ();
  int tryacquire_read ();
  int tryacquire_write ();
  //@}

private:
  Adaptee* adaptee_;
};

TAO_END_VERSIONED_NAMESPACE_DECL

#if defined (__ACE_INLINE__)
#include "orbsvcs/ESF/ESF_Busy_Lock.inl"
#endif /* __ACE_INLINE__ */

#include "orbsvcs/ESF/ESF_Busy_Lock.cpp"

#endif /* TAO_ESF_BUSY_LOCK_H */