PageRenderTime 26ms CodeModel.GetById 15ms RepoModel.GetById 0ms 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
Possible License(s): LGPL-2.1
  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. #include "linden_common.h"
  26. #include "llmortician.h"
  27. #include <list>
  28. std::list<LLMortician*> LLMortician::sGraveyard;
  29. BOOL LLMortician::sDestroyImmediate = FALSE;
  30. LLMortician::~LLMortician()
  31. {
  32. sGraveyard.remove(this);
  33. }
  34. void LLMortician::updateClass()
  35. {
  36. while (!sGraveyard.empty())
  37. {
  38. LLMortician* dead = sGraveyard.front();
  39. delete dead;
  40. }
  41. }
  42. void LLMortician::die()
  43. {
  44. // It is valid to call die() more than once on something that hasn't died yet
  45. if (sDestroyImmediate)
  46. {
  47. // *NOTE: This is a hack to ensure destruction order on shutdown (relative to non-mortician controlled classes).
  48. mIsDead = TRUE;
  49. delete this;
  50. return;
  51. }
  52. else if (!mIsDead)
  53. {
  54. mIsDead = TRUE;
  55. sGraveyard.push_back(this);
  56. }
  57. }
  58. // static
  59. void LLMortician::setZealous(BOOL b)
  60. {
  61. sDestroyImmediate = b;
  62. }