PageRenderTime 37ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/indra/llmessage/llmessagethrottle.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 80 lines | 40 code | 15 blank | 25 comment | 0 complexity | 2cfb09a88ff4a8a52bf1becca8db10fd MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llmessagethrottle.h
  3. * @brief LLMessageThrottle class used for throttling messages.
  4. *
  5. * $LicenseInfo:firstyear=2004&license=viewerlgpl$
  6. * Second Life Viewer Source Code
  7. * Copyright (C) 2010, Linden Research, Inc.
  8. *
  9. * This library is free software; you can redistribute it and/or
  10. * modify it under the terms of the GNU Lesser General Public
  11. * License as published by the Free Software Foundation;
  12. * version 2.1 of the License only.
  13. *
  14. * This library is distributed in the hope that it will be useful,
  15. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  16. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  17. * Lesser General Public License for more details.
  18. *
  19. * You should have received a copy of the GNU Lesser General Public
  20. * License along with this library; if not, write to the Free Software
  21. * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
  22. *
  23. * Linden Research, Inc., 945 Battery Street, San Francisco, CA 94111 USA
  24. * $/LicenseInfo$
  25. */
  26. #ifndef LL_LLMESSAGETHROTTLE_H
  27. #define LL_LLMESSAGETHROTTLE_H
  28. #include <deque>
  29. #include "linden_common.h"
  30. #include "lluuid.h"
  31. typedef enum e_message_throttle_categories
  32. {
  33. MTC_VIEWER_ALERT,
  34. MTC_AGENT_ALERT,
  35. MTC_EOF
  36. } EMessageThrottleCats;
  37. class LLMessageThrottleEntry
  38. {
  39. public:
  40. LLMessageThrottleEntry(const size_t hash, const U64 entry_time)
  41. : mHash(hash), mEntryTime(entry_time) {}
  42. size_t getHash() const { return mHash; }
  43. U64 getEntryTime() const { return mEntryTime; }
  44. protected:
  45. size_t mHash;
  46. U64 mEntryTime;
  47. };
  48. class LLMessageThrottle
  49. {
  50. public:
  51. LLMessageThrottle();
  52. ~LLMessageThrottle();
  53. BOOL addViewerAlert (const LLUUID& to, const std::string& mesg);
  54. BOOL addAgentAlert (const LLUUID& agent, const LLUUID& task, const std::string& mesg);
  55. void pruneEntries();
  56. protected:
  57. typedef std::deque<LLMessageThrottleEntry> message_list_t;
  58. typedef std::deque<LLMessageThrottleEntry>::iterator message_list_iterator_t;
  59. typedef std::deque<LLMessageThrottleEntry>::reverse_iterator message_list_reverse_iterator_t;
  60. typedef std::deque<LLMessageThrottleEntry>::const_iterator message_list_const_iterator_t;
  61. typedef std::deque<LLMessageThrottleEntry>::const_reverse_iterator message_list_const_reverse_iterator_t;
  62. message_list_t mMessageList[MTC_EOF];
  63. };
  64. extern LLMessageThrottle gMessageThrottle;
  65. #endif