PageRenderTime 34ms CodeModel.GetById 21ms app.highlight 7ms RepoModel.GetById 1ms 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
 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
27#ifndef LL_LLHEARTBEAT_H
28#define LL_LLHEARTBEAT_H
29
30#include "linden_common.h"
31
32#include "lltimer.h"
33
34// Note: Win32 does not support the heartbeat/smackdown system;
35//   heartbeat-delivery turns into a no-op there.
36
37class LL_COMMON_API LLHeartbeat
38{
39public:
40	// secs_between_heartbeat: after a heartbeat is successfully delivered,
41	//   we suppress sending more for this length of time.
42	// aggressive_heartbeat_panic_secs: if we've been failing to
43	//   successfully deliver heartbeats for this length of time then
44	//   we block for a while until we're really sure we got one delivered.
45	// aggressive_heartbeat_max_blocking_secs: this is the length of
46	//   time we block for when we're aggressively ensuring that a 'panic'
47	//   heartbeat was delivered.
48	LLHeartbeat(F32 secs_between_heartbeat = 5.0f,
49		    F32 aggressive_heartbeat_panic_secs = 10.0f,
50		    F32 aggressive_heartbeat_max_blocking_secs = 4.0f);
51	~LLHeartbeat();
52
53	bool send(F32 timeout_sec = 0.0f);
54	void setSuppressed(bool is_suppressed);
55
56private:
57	int rawSend();
58	int rawSendWithTimeout(F32 timeout_sec);
59	F32 mSecsBetweenHeartbeat;
60	F32 mAggressiveHeartbeatPanicSecs;
61	F32 mAggressiveHeartbeatMaxBlockingSecs;
62	bool mSuppressed;
63	LLTimer mBeatTimer;
64	LLTimer mPanicTimer;
65	LLTimer mTimeoutTimer;
66};
67
68#endif // LL_HEARTBEAT_H