summaryrefslogtreecommitdiff
path: root/ACE/ace/Null_Condition.h
blob: db68b6c0e0a48e3bfb6dd83e786767beebae1bac (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
// -*- C++ -*-

//==========================================================================
/**
 *  @file    Null_Condition.h
 *
 *  @author Douglas C. Schmidt <d.schmidt@vanderbilt.edu>
 */
//==========================================================================

#ifndef ACE_NULL_CONDITION_H
#define ACE_NULL_CONDITION_H
#include /**/ "ace/pre.h"

#include "ace/Null_Mutex.h"
#include "ace/Condition_T.h"

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

#include "ace/os_include/os_errno.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

class ACE_Time_Value;
class ACE_Condition_Attributes;
template <class MUTEX> class ACE_Condition;

/**
 * @brief ACE_Condition template specialization written using
 * ACE_Null_Mutexes. Implements a do nothing ACE_Condition
 * specialization, i.e., all methods are no ops.
 */
template <>
class ACE_Condition<ACE_Null_Mutex>
{
public:
  ACE_Condition (const ACE_Null_Mutex &m,
                 const ACE_TCHAR * = 0,
                 void * = 0)
    : mutex_ ((ACE_Null_Mutex &) m) {}

  ACE_Condition (const ACE_Null_Mutex &m,
                 const ACE_Condition_Attributes &,
                 const ACE_TCHAR * = 0,
                 void * = 0)
  : mutex_ ((ACE_Null_Mutex &) m) {}

  ~ACE_Condition () = default;

  /// Returns 0.
  int remove () {return 0;}

  /// Returns -1 with @c errno == @c ETIME.
  int wait (const ACE_Time_Value * = 0) {errno = ETIME; return -1;}

  /// Returns -1 with @c errno == @c ETIME.
  int wait (ACE_Null_Mutex &,
            const ACE_Time_Value * = 0) {errno = ETIME; return -1;}

  /// Returns 0.
  int signal () {return 0;}

  /// Returns 0.
  int broadcast () {return 0;}
  ACE_Null_Mutex &mutex () {return this->mutex_;};

  /// Dump the state of an object.
  void dump () const {}

  // ACE_ALLOC_HOOK_DECLARE;
  // Declare the dynamic allocation hooks.

protected:
  ACE_Null_Mutex &mutex_; // Reference to mutex lock.

private:
  void operator= (const ACE_Condition<ACE_Null_Mutex> &) = delete;
  ACE_Condition (const ACE_Condition<ACE_Null_Mutex> &) = delete;
};

typedef ACE_Condition<ACE_Null_Mutex> ACE_Null_Condition;

ACE_END_VERSIONED_NAMESPACE_DECL

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