summaryrefslogtreecommitdiff
path: root/indra
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2016-04-22 12:07:27 -0700
committerRider Linden <rider@lindenlab.com>2016-04-22 12:07:27 -0700
commit899489ae0a4bc4eb187e7813e338b937384a1866 (patch)
treee83b388e1f35d1fe53701203131cd94ac5216ec2 /indra
parent8f4be8bb869e3cde034607cbe0cb8272005f08b8 (diff)
MAINT-6336: Centralize waiting on event pump with a timeout. Shorten the lifespan of a timeout event pump lifespan to be no longer than necessary. Change all references to the LLEventTimer to instead uses the centralized version.
Diffstat (limited to 'indra')
-rwxr-xr-xindra/llcommon/lleventcoro.cpp9
-rwxr-xr-xindra/llcommon/lleventcoro.h2
-rwxr-xr-xindra/llcommon/lleventfilter.cpp4
-rwxr-xr-xindra/llcommon/lleventfilter.h3
-rwxr-xr-xindra/newview/llvoicevivox.cpp32
5 files changed, 26 insertions, 24 deletions
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp
index 578a2b62c8..44291eb711 100755
--- a/indra/llcommon/lleventcoro.cpp
+++ b/indra/llcommon/lleventcoro.cpp
@@ -229,6 +229,15 @@ LLSD llcoro::postAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requ
return value;
}
+LLSD llcoro::suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& pump, F32 timeoutin, const LLSD &timeoutResult)
+{
+ LLEventTimeout timeoutPump(pump);
+
+ timeoutPump.eventAfter(timeoutin, timeoutResult);
+ return llcoro::suspendUntilEventOn(timeoutPump);
+
+}
+
namespace
{
diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h
index 2105faf861..19c68e1f35 100755
--- a/indra/llcommon/lleventcoro.h
+++ b/indra/llcommon/lleventcoro.h
@@ -147,6 +147,8 @@ LLSD suspendUntilEventOn(const LLEventPumpOrPumpName& pump)
return postAndSuspend(LLSD(), LLEventPumpOrPumpName(), pump);
}
+LLSD suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& pump, F32 timeoutin, const LLSD &timeoutResult);
+
} // namespace llcoro
/// return type for two-pump variant of suspendUntilEventOn()
diff --git a/indra/llcommon/lleventfilter.cpp b/indra/llcommon/lleventfilter.cpp
index d36a107254..64ab58adcd 100755
--- a/indra/llcommon/lleventfilter.cpp
+++ b/indra/llcommon/lleventfilter.cpp
@@ -39,9 +39,9 @@
#include "llsdutil.h" // llsd_matches()
LLEventFilter::LLEventFilter(LLEventPump& source, const std::string& name, bool tweak):
- LLEventStream(name, tweak)
+ LLEventStream(name, tweak),
+ mSource(source.listen(getName(), boost::bind(&LLEventFilter::post, this, _1)))
{
- source.listen(getName(), boost::bind(&LLEventFilter::post, this, _1));
}
LLEventMatching::LLEventMatching(const LLSD& pattern):
diff --git a/indra/llcommon/lleventfilter.h b/indra/llcommon/lleventfilter.h
index 8e01326823..15bac5fd73 100755
--- a/indra/llcommon/lleventfilter.h
+++ b/indra/llcommon/lleventfilter.h
@@ -49,6 +49,9 @@ public:
/// Post an event to all listeners
virtual bool post(const LLSD& event) = 0;
+
+private:
+ LLTempBoundListener mSource;
};
/**
diff --git a/indra/newview/llvoicevivox.cpp b/indra/newview/llvoicevivox.cpp
index ca0509c524..043ddc904b 100755
--- a/indra/newview/llvoicevivox.cpp
+++ b/indra/newview/llvoicevivox.cpp
@@ -903,8 +903,6 @@ bool LLVivoxVoiceClient::loginToVivox()
LLSD timeoutResult;
timeoutResult["login"] = LLSD::String("timeout");
- LLEventTimeout voicePumpTimeout(voicePump);
-
int loginRetryCount(0);
bool response_ok(false);
@@ -920,8 +918,7 @@ bool LLVivoxVoiceClient::loginToVivox()
send_login = false;
- voicePumpTimeout.eventAfter(LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
- LLSD result = llcoro::suspendUntilEventOn(voicePump);
+ LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
if (result.has("login"))
@@ -1018,10 +1015,7 @@ void LLVivoxVoiceClient::logoutOfVivox(bool wait)
LLSD timeoutResult;
timeoutResult["logout"] = LLSD::String("timeout");
- LLEventTimeout voicePumpTimeout(voicePump);
-
- voicePumpTimeout.eventAfter(LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
- LLSD result = llcoro::suspendUntilEventOn(voicePumpTimeout);
+ LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, LOGIN_ATTEMPT_TIMEOUT, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
@@ -1231,12 +1225,9 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
// This is a cheap way to make sure both have happened before proceeding.
do
{
- LLEventTimeout voicePumpTimeout(voicePump);
-
- voicePumpTimeout.eventAfter(SESSION_JOIN_TIMEOUT, timeoutResult);
- result = llcoro::suspendUntilEventOn(voicePumpTimeout);
+ result = llcoro::suspendUntilEventOnWithTimeout(voicePump, SESSION_JOIN_TIMEOUT, timeoutResult);
- LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
+ LL_INFOS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
if (result.has("session"))
{
if (result.has("handle"))
@@ -1249,6 +1240,9 @@ bool LLVivoxVoiceClient::addAndJoinSession(const sessionStatePtr_t &nextSession)
}
std::string message = result["session"].asString();
+// if (message == "joined")
+// message = "removed";
+
if ((message == "added") || (message == "created"))
added = true;
else if (message == "joined")
@@ -1510,7 +1504,6 @@ bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session)
timeoutEvent["timeout"] = LLSD::Boolean(true);
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
- LLEventTimeout timeout(voicePump);
mIsInChannel = true;
mMuteMicDirty = true;
@@ -1562,8 +1555,7 @@ bool LLVivoxVoiceClient::runSession(const sessionStatePtr_t &session)
sendLocalAudioUpdates();
mIsInitialized = true;
- timeout.eventAfter(UPDATE_THROTTLE_SECONDS, timeoutEvent);
- LLSD result = llcoro::suspendUntilEventOn(timeout);
+ LLSD result = llcoro::suspendUntilEventOnWithTimeout(voicePump, UPDATE_THROTTLE_SECONDS, timeoutEvent);
if (!result.has("timeout")) // logging the timeout event spams the log
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
if (result.has("session"))
@@ -1667,8 +1659,6 @@ int LLVivoxVoiceClient::voiceRecordBuffer()
LL_INFOS("Voice") << "Recording voice buffer" << LL_ENDL;
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
- LLEventTimeout timeout(voicePump);
- timeout.eventAfter(CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LLSD result;
captureBufferRecordStartSendMessage();
@@ -1676,7 +1666,7 @@ int LLVivoxVoiceClient::voiceRecordBuffer()
do
{
- result = llcoro::suspendUntilEventOn(voicePump);
+ result = llcoro::suspendUntilEventOnWithTimeout(voicePump, CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
} while (!result.has("recplay"));
@@ -1700,12 +1690,10 @@ int LLVivoxVoiceClient::voicePlaybackBuffer()
LL_INFOS("Voice") << "Playing voice buffer" << LL_ENDL;
LLEventPump &voicePump = LLEventPumps::instance().obtain("vivoxClientPump");
- LLEventTimeout timeout(voicePump);
LLSD result;
do
{
- timeout.eventAfter(CAPTURE_BUFFER_MAX_TIME, timeoutResult);
captureBufferPlayStartSendMessage(mPreviewVoiceFont);
// Store the voice font being previewed, so that we know to restart if it changes.
@@ -1716,7 +1704,7 @@ int LLVivoxVoiceClient::voicePlaybackBuffer()
// Update UI, should really use a separate callback.
notifyVoiceFontObservers();
- result = llcoro::suspendUntilEventOn(timeout);
+ result = llcoro::suspendUntilEventOnWithTimeout(voicePump, CAPTURE_BUFFER_MAX_TIME, timeoutResult);
LL_DEBUGS("Voice") << "event=" << ll_pretty_print_sd(result) << LL_ENDL;
} while (!result.has("recplay"));