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

/indra/llcommon/llheartbeat.h

https://bitbucket.org/lindenlab/viewer-beta/
C++ Header | 68 lines | 25 code | 8 blank | 35 comment | 0 complexity | 7fb5837746f7831d778e594f0afaf833 MD5 | raw file
Possible License(s): LGPL-2.1
  1. /**
  2. * @file llheartbeat.h
  3. * @brief Class encapsulating logic for telling a watchdog that we live.
  4. *
  5. * $LicenseInfo:firstyear=2008&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_LLHEARTBEAT_H
  27. #define LL_LLHEARTBEAT_H
  28. #include "linden_common.h"
  29. #include "lltimer.h"
  30. // Note: Win32 does not support the heartbeat/smackdown system;
  31. // heartbeat-delivery turns into a no-op there.
  32. class LL_COMMON_API LLHeartbeat
  33. {
  34. public:
  35. // secs_between_heartbeat: after a heartbeat is successfully delivered,
  36. // we suppress sending more for this length of time.
  37. // aggressive_heartbeat_panic_secs: if we've been failing to
  38. // successfully deliver heartbeats for this length of time then
  39. // we block for a while until we're really sure we got one delivered.
  40. // aggressive_heartbeat_max_blocking_secs: this is the length of
  41. // time we block for when we're aggressively ensuring that a 'panic'
  42. // heartbeat was delivered.
  43. LLHeartbeat(F32 secs_between_heartbeat = 5.0f,
  44. F32 aggressive_heartbeat_panic_secs = 10.0f,
  45. F32 aggressive_heartbeat_max_blocking_secs = 4.0f);
  46. ~LLHeartbeat();
  47. bool send(F32 timeout_sec = 0.0f);
  48. void setSuppressed(bool is_suppressed);
  49. private:
  50. int rawSend();
  51. int rawSendWithTimeout(F32 timeout_sec);
  52. F32 mSecsBetweenHeartbeat;
  53. F32 mAggressiveHeartbeatPanicSecs;
  54. F32 mAggressiveHeartbeatMaxBlockingSecs;
  55. bool mSuppressed;
  56. LLTimer mBeatTimer;
  57. LLTimer mPanicTimer;
  58. LLTimer mTimeoutTimer;
  59. };
  60. #endif // LL_HEARTBEAT_H