summaryrefslogtreecommitdiff
path: root/ACE/ace/Init_ACE.cpp
blob: 65e551ca81cd3c12e3e79d0cd118f3de330e338e (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
#include "ace/Init_ACE.h"

#include "ace/Object_Manager.h"

ACE_BEGIN_VERSIONED_NAMESPACE_DECL

unsigned int ACE::init_fini_count_ = 0;

int
ACE::init ()
{
  // Don't use ACE_TRACE, because Object_Manager might not have been
  // instantiated yet.
  // ACE_TRACE ("ACE::init");
  ++ACE::init_fini_count_;

  return ACE_Object_Manager::instance ()->init ();
}

int
ACE::fini ()
{
  ACE_TRACE ("ACE::fini");

  if (ACE::init_fini_count_ > 0)
    {
      if (--ACE::init_fini_count_ == 0)
        return ACE_Object_Manager::instance ()->fini ();
      else
        // Wait for remaining fini () calls.
        return 1;
    }
  else
    // More ACE::fini () calls than ACE::init () calls.  Bad
    // application!
    return -1;
}

ACE_END_VERSIONED_NAMESPACE_DECL