Skip to content
Snippets Groups Projects
llmortician.cpp 853 B
Newer Older
  • Learn to ignore specific revisions
  • James Cook's avatar
    James Cook committed
    /** 
     * @file llmortician.cpp
     *
     * Copyright (c) 2005-$CurrentYear$, Linden Research, Inc.
     * $License$
     */
    
    
    #include "linden_common.h"
    
    James Cook's avatar
    James Cook committed
    #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;
    }