summaryrefslogtreecommitdiff
path: root/indra/llcommon/llcleanup.h
blob: 0f567ed5f6afcd38e3fb42cc54668cd2556cf3d4 (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
/**
 * @file   llcleanup.h
 * @author Nat Goodspeed
 * @date   2015-05-20
 * @brief  Mechanism for cleaning up subsystem resources
 * 
 * $LicenseInfo:firstyear=2015&license=viewerlgpl$
 * Copyright (c) 2015, Linden Research, Inc.
 * $/LicenseInfo$
 */

#if ! defined(LL_LLCLEANUP_H)
#define LL_LLCLEANUP_H

#include <boost/current_function.hpp>

// Instead of directly calling SomeClass::cleanupClass(), use
// SUBSYSTEM_CLEANUP(SomeClass);
// This logs the call as well as performing it. That gives us a baseline
// subsystem shutdown order against which to compare subsequent dynamic
// shutdown schemes.
#define SUBSYSTEM_CLEANUP(CLASSNAME)                                    \
    do {                                                                \
        log_subsystem_cleanup(LLError::LEVEL_INFO, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, #CLASSNAME); \
        CLASSNAME::cleanupClass();                                      \
    } while (0)

#define SUBSYSTEM_CLEANUP_DBG(CLASSNAME)                                    \
    do {                                                                \
        log_subsystem_cleanup(LLError::LEVEL_DEBUG, __FILE__, __LINE__, BOOST_CURRENT_FUNCTION, #CLASSNAME); \
        CLASSNAME::cleanupClass();                                      \
    } while (0)
// Use ancient do { ... } while (0) macro trick to permit a block of
// statements with the same syntax as a single statement.

void log_subsystem_cleanup(LLError::ELevel level,
                           const char* file,
                           int line,
                           const char* function,
                           const char* classname);

#endif /* ! defined(LL_LLCLEANUP_H) */