summaryrefslogtreecommitdiff
path: root/indra/llcommon
diff options
context:
space:
mode:
authorRider Linden <rider@lindenlab.com>2016-04-26 11:56:25 -0700
committerRider Linden <rider@lindenlab.com>2016-04-26 11:56:25 -0700
commitdd2311b993d137c538ca57b4360669db6d7fbfa0 (patch)
treee7b3553da33dedfd436192e6ae555d884e58ce16 /indra/llcommon
parent4d9dd3271b1a015d9afd21767e579a4cd71982ed (diff)
MAINT-6336: Put the timeout upstream of the suspending pump and fire the timeout it. Also some cleanup on LLSD construction in vivox.
Diffstat (limited to 'indra/llcommon')
-rwxr-xr-xindra/llcommon/lleventcoro.cpp21
-rwxr-xr-xindra/llcommon/lleventcoro.h5
-rwxr-xr-xindra/llcommon/lleventfilter.h14
-rwxr-xr-xindra/llcommon/llevents.h6
4 files changed, 40 insertions, 6 deletions
diff --git a/indra/llcommon/lleventcoro.cpp b/indra/llcommon/lleventcoro.cpp
index 44291eb711..c8c43dc334 100755
--- a/indra/llcommon/lleventcoro.cpp
+++ b/indra/llcommon/lleventcoro.cpp
@@ -229,13 +229,26 @@ LLSD llcoro::postAndSuspend(const LLSD& event, const LLEventPumpOrPumpName& requ
return value;
}
-LLSD llcoro::suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& pump, F32 timeoutin, const LLSD &timeoutResult)
+LLSD llcoro::suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& suspendPumpOrName,
+ F32 timeoutin, const LLSD &timeoutResult)
{
- LLEventTimeout timeoutPump(pump);
+ /**
+ * The timeout pump is attached upstream of of the waiting pump and will
+ * pass the timeout event through it. We CAN NOT attach downstream since
+ * doing so will cause the suspendPump to fire any waiting events immediately
+ * and they will be lost. This becomes especially problematic with the
+ * LLEventTimeout(pump) constructor which will also attempt to fire those
+ * events using the virtual listen_impl method in the not yet fully constructed
+ * timeoutPump.
+ */
+ LLEventTimeout timeoutPump;
+ LLEventPump &suspendPump = suspendPumpOrName.getPump();
+
+ LLTempBoundListener timeoutListener = timeoutPump.listen(suspendPump.getName(),
+ boost::bind(&LLEventPump::post, &suspendPump, _1));
timeoutPump.eventAfter(timeoutin, timeoutResult);
- return llcoro::suspendUntilEventOn(timeoutPump);
-
+ return llcoro::suspendUntilEventOn(suspendPump);
}
namespace
diff --git a/indra/llcommon/lleventcoro.h b/indra/llcommon/lleventcoro.h
index 19c68e1f35..87926c692d 100755
--- a/indra/llcommon/lleventcoro.h
+++ b/indra/llcommon/lleventcoro.h
@@ -147,7 +147,10 @@ LLSD suspendUntilEventOn(const LLEventPumpOrPumpName& pump)
return postAndSuspend(LLSD(), LLEventPumpOrPumpName(), pump);
}
-LLSD suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& pump, F32 timeoutin, const LLSD &timeoutResult);
+/// Suspend the coroutine until an event is fired on the identified pump
+/// or the timeout duration has elapsed. If the timeout duration
+/// elapses the specified LLSD is returned.
+LLSD suspendUntilEventOnWithTimeout(const LLEventPumpOrPumpName& suspendPumpOrName, F32 timeoutin, const LLSD &timeoutResult);
} // namespace llcoro
diff --git a/indra/llcommon/lleventfilter.h b/indra/llcommon/lleventfilter.h
index 15bac5fd73..66f3c14869 100755
--- a/indra/llcommon/lleventfilter.h
+++ b/indra/llcommon/lleventfilter.h
@@ -188,7 +188,19 @@ private:
Action mAction;
};
-/// Production implementation of LLEventTimoutBase
+/**
+ * Production implementation of LLEventTimoutBase.
+ *
+ * @NOTE: Caution should be taken when using the LLEventTimeout(LLEventPump &)
+ * constructor to ensure that the upstream event pump is not an LLEventMaildrop
+ * or any other kind of store and forward pump which may have events outstanding.
+ * Using this constructor will cause the upstream event pump to fire any pending
+ * events and could result in the invocation of a virtual method before the timeout
+ * has been fully constructed. The timeout should instead be connected upstream
+ * from the event pump and attached using the listen method.
+ * See llcoro::suspendUntilEventOnWithTimeout() for an example.
+ */
+
class LL_COMMON_API LLEventTimeout: public LLEventTimeoutBase
{
public:
diff --git a/indra/llcommon/llevents.h b/indra/llcommon/llevents.h
index 6175329a9d..ba4fcd766e 100755
--- a/indra/llcommon/llevents.h
+++ b/indra/llcommon/llevents.h
@@ -616,6 +616,12 @@ public:
* a queue. Subsequent attaching listeners will receive stored events from the queue
* until a listener indicates that the event has been handled. In order to receive
* multiple events from a mail drop the listener must disconnect and reconnect.
+ *
+ * @NOTE: When using an LLEventMailDrop (or LLEventQueue) with a LLEventTimeout or
+ * LLEventFilter attaching the filter downstream using Timeout's constructor will
+ * cause the MailDrop to discharge any of it's stored events. The timeout should
+ * instead be connected upstream using its listen() method.
+ * See llcoro::suspendUntilEventOnWithTimeout() for an example.
*/
class LL_COMMON_API LLEventMailDrop : public LLEventStream
{