Skip to content
Snippets Groups Projects
llmortician.cpp 826 B
Newer Older
James Cook's avatar
James Cook committed
/** 
 * @file llmortician.cpp
 *
 * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
 * $License$
 */

#include "llmortician.h"

#include <list>

std::list<LLMortician*> gGraveyard;

BOOL LLMortician::sDestroyImmediate = FALSE;

LLMortician::~LLMortician() 
{
	gGraveyard.remove(this);
}

void LLMortician::updateClass() 
{
	while (!gGraveyard.empty()) 
	{
		LLMortician* dead = gGraveyard.front();
		delete dead;
	}
}

void LLMortician::die() 
{
	// It is valid to call die() more than once on something that hasn't died yet
	if (sDestroyImmediate)
	{
		// *NOTE: This is a hack to ensure destruction order on shutdown.
James Cook's avatar
James Cook committed
		mIsDead = TRUE;
		delete this;
		return;
	}
	else if (!mIsDead)
	{
		mIsDead = TRUE;
		gGraveyard.push_back(this);
	}
}

// static
void LLMortician::setZealous(BOOL b)
{
	sDestroyImmediate = b;
}