PageRenderTime 9ms CodeModel.GetById 2ms app.highlight 4ms RepoModel.GetById 2ms app.codeStats 0ms

/indra/llcommon/llmortician.cpp

https://bitbucket.org/lindenlab/viewer-beta/
C++ | 70 lines | 35 code | 8 blank | 27 comment | 4 complexity | 182abfc16dffe4c221655ea325f1f18f MD5 | raw file
 1/** 
 2 * @file llmortician.cpp
 3 *
 4 * $LicenseInfo:firstyear=2005&license=viewerlgpl$
 5 * Second Life Viewer Source Code
 6 * Copyright (C) 2010, Linden Research, Inc.
 7 * 
 8 * This library is free software; you can redistribute it and/or
 9 * modify it under the terms of the GNU Lesser General Public
10 * License as published by the Free Software Foundation;
11 * version 2.1 of the License only.
12 * 
13 * This library is distributed in the hope that it will be useful,
14 * but WITHOUT ANY WARRANTY; without even the implied warranty of
15 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 * Lesser General Public License for more details.
17 * 
18 * You should have received a copy of the GNU Lesser General Public
19 * License along with this library; if not, write to the Free Software
20 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
21 * 
22 * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA
23 * $/LicenseInfo$
24 */
25
26#include "linden_common.h"
27#include "llmortician.h"
28
29#include <list>
30
31std::list<LLMortician*> LLMortician::sGraveyard;
32
33BOOL LLMortician::sDestroyImmediate = FALSE;
34
35LLMortician::~LLMortician() 
36{
37	sGraveyard.remove(this);
38}
39
40void LLMortician::updateClass() 
41{
42	while (!sGraveyard.empty()) 
43	{
44		LLMortician* dead = sGraveyard.front();
45		delete dead;
46	}
47}
48
49void LLMortician::die() 
50{
51	// It is valid to call die() more than once on something that hasn't died yet
52	if (sDestroyImmediate)
53	{
54		// *NOTE: This is a hack to ensure destruction order on shutdown (relative to non-mortician controlled classes).
55		mIsDead = TRUE;
56		delete this;
57		return;
58	}
59	else if (!mIsDead)
60	{
61		mIsDead = TRUE;
62		sGraveyard.push_back(this);
63	}
64}
65
66// static
67void LLMortician::setZealous(BOOL b)
68{
69	sDestroyImmediate = b;
70}