summaryrefslogtreecommitdiff
path: root/TAO/tao/PortableServer/POA_Guard.cpp
blob: cbf2eb0bba740f8ec01888f77ffdca1ef887f4cf (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
// $Id$

#include "POA_Guard.h"
#include "Root_POA.h"
#include "tao/ORB_Constants.h"

ACE_RCSID(PortableServer,
          POA_Guard,
          "$Id$")

namespace TAO
{
  namespace Portable_Server
  {
    POA_Guard::POA_Guard (::TAO_Root_POA &poa
                          ACE_ENV_ARG_DECL,
                          int check_for_destruction)
      : guard_ (poa.lock ())
    {
      if (!this->guard_.locked ())
        ACE_THROW (
          CORBA::INTERNAL (
            CORBA::SystemException::_tao_minor_code (
              TAO_GUARD_FAILURE,
              0),
            CORBA::COMPLETED_NO));

      // Check if a non-servant upcall is in progress.  If a non-servant
      // upcall is in progress, wait for it to complete.  Unless of
      // course, the thread making the non-servant upcall is this thread.
      poa.object_adapter ().wait_for_non_servant_upcalls_to_complete (ACE_ENV_SINGLE_ARG_PARAMETER);
      ACE_CHECK;

      if (check_for_destruction &&
          poa.cleanup_in_progress ())
        ACE_THROW (
          CORBA::BAD_INV_ORDER (
            CORBA::SystemException::_tao_minor_code (
              TAO_POA_BEING_DESTROYED,
              0),
            CORBA::COMPLETED_NO));
    }
  }
}