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

#if defined (ACE_LACKS_INLINE_FUNCTIONS)
#include "ace/Init_ACE.i"
#endif /* ACE_LACKS_INLINE_FUNCTIONS */

#include "ace/Object_Manager.h"
#include "ace/Trace.h"

ACE_RCSID (ace,
           Init_ACE,
           "$Id$")

// Static data members.
unsigned int ACE_Init_ACE::init_fini_count_ = 0;

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

  ++init_fini_count_;

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

int
ACE_Init_ACE::fini (void)
{
  ACE_TRACE ("ACE_Init_ACE::fini");

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