llmortician.cpp 2.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273
  1. /**
  2. * @file llmortician.cpp
  3. *
  4. * $LicenseInfo:firstyear=2005&license=viewergpl$
  5. *
  6. * Copyright (c) 2005-2009, Linden Research, Inc.
  7. *
  8. * Second Life Viewer Source Code
  9. * The source code in this file ("Source Code") is provided by Linden Lab
  10. * to you under the terms of the GNU General Public License, version 2.0
  11. * ("GPL"), unless you have obtained a separate licensing agreement
  12. * ("Other License"), formally executed by you and Linden Lab. Terms of
  13. * the GPL can be found in doc/GPL-license.txt in this distribution, or
  14. * online at http://secondlifegrid.net/programs/open_source/licensing/gplv2
  15. *
  16. * There are special exceptions to the terms and conditions of the GPL as
  17. * it is applied to this Source Code. View the full text of the exception
  18. * in the file doc/FLOSS-exception.txt in this software distribution, or
  19. * online at
  20. * http://secondlifegrid.net/programs/open_source/licensing/flossexception
  21. *
  22. * By copying, modifying or distributing this software, you acknowledge
  23. * that you have read and understood your obligations described above,
  24. * and agree to abide by those obligations.
  25. *
  26. * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
  27. * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
  28. * COMPLETENESS OR PERFORMANCE.
  29. * $/LicenseInfo$
  30. */
  31. #include "linden_common.h"
  32. #include "llmortician.h"
  33. std::list<LLMortician*> LLMortician::sGraveyard;
  34. bool LLMortician::sDestroyImmediate = false;
  35. //virtual
  36. LLMortician::~LLMortician()
  37. {
  38. sGraveyard.remove(this);
  39. }
  40. void LLMortician::die()
  41. {
  42. // It is valid to call die() more than once on something that has not died
  43. // yet
  44. if (sDestroyImmediate)
  45. {
  46. // *NOTE: This is a hack to ensure destruction order on shutdown
  47. // (relative to non-mortician controlled classes).
  48. mIsDead = true;
  49. delete this;
  50. return;
  51. }
  52. if (!mIsDead)
  53. {
  54. mIsDead = true;
  55. sGraveyard.push_back(this);
  56. }
  57. }
  58. //static
  59. void LLMortician::updateClass()
  60. {
  61. while (!sGraveyard.empty())
  62. {
  63. LLMortician* dead = sGraveyard.front();
  64. delete dead;
  65. }
  66. }