summaryrefslogtreecommitdiff
path: root/TAO/tao/CSD_ThreadPool/CSD_TP_Synch_Helper.inl
blob: f4c5a1380c17117a9de7c5621f1f018d979450c0 (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
// -*- C++ -*-
//
// $Id$

TAO_BEGIN_VERSIONED_NAMESPACE_DECL

ACE_INLINE
TAO::CSD::TP_Synch_Helper::TP_Synch_Helper()
  : state_(PENDING),
    condition_(this->lock_)
{
}


ACE_INLINE
TAO::CSD::TP_Synch_Helper::~TP_Synch_Helper()
{
}


ACE_INLINE
bool
TAO::CSD::TP_Synch_Helper::wait_while_pending()
{
  GuardType guard(this->lock_);

  while (this->state_ == PENDING)
    {
      this->condition_.wait();
    }

  return (this->state_ == DISPATCHED);
}


ACE_INLINE
void
TAO::CSD::TP_Synch_Helper::dispatched()
{
  GuardType guard(this->lock_);
  this->state_ = DISPATCHED;
  this->condition_.signal();
}


ACE_INLINE
void
TAO::CSD::TP_Synch_Helper::cancelled()
{
  GuardType guard(this->lock_);
  this->state_ = CANCELLED;
  this->condition_.signal();
}

TAO_END_VERSIONED_NAMESPACE_DECL