summaryrefslogtreecommitdiff
path: root/CIAO/DAnCE/tools/Completion/Completion_Counter_Base.inl
blob: 2ad8282780bb6b0fedd3a04027d35198317027d4 (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
// -*- C++ -*-
//
// $Id$

namespace DAnCE
  {

    template <class ACE_LOCK>
    ACE_INLINE Completion_Counter_Base<ACE_LOCK>::~Completion_Counter_Base ()
      {
      }

    template <class ACE_LOCK>
    ACE_INLINE Completion_Counter_Base<ACE_LOCK>::Completion_Counter_Base (
        unsigned int exec_count,
        unsigned int fail_count)
      : exec_count_ (exec_count), fail_count_ (fail_count)
      {
      }

    template <class ACE_LOCK>
    ACE_INLINE void
    Completion_Counter_Base<ACE_LOCK>::decrement_exec_count ()
      {
        ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

        --this->exec_count_;

        if (this->exec_count_ == 0)
          {
            if (this->fail_count_ > 0)
            {
              this->on_all_completed_with_failure ();
            }
          else
            {
              this->on_all_completed ();
            }
          }
      }

    template <class ACE_LOCK>
    ACE_INLINE void
    Completion_Counter_Base<ACE_LOCK>::increment_fail_count (const char* error)
      {
        ACE_GUARD (ACE_LOCK, ace_mon, this->lock_);

        ++this->fail_count_;
        this->errors_.push_back (error);
      }

    template <class ACE_LOCK>
    ACE_INLINE unsigned int
    Completion_Counter_Base<ACE_LOCK>::exec_count ()
      {
        ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0);

        return this->exec_count_;
      }

    template <class ACE_LOCK>
    ACE_INLINE unsigned int
    Completion_Counter_Base<ACE_LOCK>::fail_count ()
      {
        ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, 0);

        return this->fail_count_;
      }

    template <class ACE_LOCK>
    ACE_INLINE bool
    Completion_Counter_Base<ACE_LOCK>::all_completed ()
      {
        ACE_GUARD_RETURN (ACE_LOCK, ace_mon, this->lock_, false);

        return (this->exec_count_ == 0);
      }

    template <class ACE_LOCK>
    ACE_INLINE
    const typename Completion_Counter_Base<ACE_LOCK>::errors_type&
    Completion_Counter_Base<ACE_LOCK>::errors () const
      {
        return this->errors_;
      }

    template <class ACE_LOCK>
    ACE_INLINE unsigned int
    Completion_Counter_Base<ACE_LOCK>::exec_count_i ()
      {
        return this->exec_count_;
      }

    template <class ACE_LOCK>
    ACE_INLINE unsigned int
    Completion_Counter_Base<ACE_LOCK>::fail_count_i ()
      {
        return this->fail_count_;
      }

  } /*DAnCE */