summaryrefslogtreecommitdiff
path: root/indra/newview/llattachmentsmgr.h
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llattachmentsmgr.h')
-rwxr-xr-xindra/newview/llattachmentsmgr.h105
1 files changed, 82 insertions, 23 deletions
diff --git a/indra/newview/llattachmentsmgr.h b/indra/newview/llattachmentsmgr.h
index 1d8ab74dfd..d56d6eb27b 100755
--- a/indra/newview/llattachmentsmgr.h
+++ b/indra/newview/llattachmentsmgr.h
@@ -32,42 +32,101 @@
class LLViewerInventoryItem;
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+//--------------------------------------------------------------------------------
// LLAttachmentsMgr
//
-// The sole purpose of this class is to take attachment
-// requests, queue them up, and send them all at once.
-// This handles situations where the viewer may request
-// a bunch of attachments at once in a short period of
-// time, where each of the requests would normally be
-// sent as a separate message versus being batched into
-// one single message.
-//
-// The intent of this batching is to reduce viewer->server
-// traffic.
-//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+// This class manages batching up of requests at two stages of
+// attachment rezzing.
+//
+// First, attachments requested to rez get saved in
+// mPendingAttachments and sent as a single
+// RezMultipleAttachmentsFromInv request. This batching is needed
+// mainly because of weaknessing the UI element->inventory item
+// handling, such that we don't always know when we are requesting
+// multiple items. Now they just pile up and get swept into a single
+// request during the idle loop.
+//
+// Second, after attachments arrive, we need to generate COF links for
+// them. There are both efficiency and UI correctness reasons why it
+// is better to request all the COF links at once and run a single
+// callback after they all complete. Given the vagaries of the
+// attachment system, there is no guarantee that we will get all the
+// attachments we ask for, but we frequently do. So in the common case
+// that all the desired attachments arrive fairly quickly, we generate
+// a single batched request for COF links. If attachments arrive late
+// or not at all, we will still issue COF link requests once a timeout
+// value has been exceeded.
+//
+// To handle attachments that never arrive, we forget about requests
+// that exceed a timeout value.
+//--------------------------------------------------------------------------------
class LLAttachmentsMgr: public LLSingleton<LLAttachmentsMgr>
{
public:
- LLAttachmentsMgr();
- virtual ~LLAttachmentsMgr();
-
- void addAttachment(const LLUUID& item_id,
- const U8 attachment_pt,
- const BOOL add);
- static void onIdle(void *);
-protected:
- void onIdle();
-private:
+ // Stores info for attachments that will be requested during idle.
struct AttachmentsInfo
{
LLUUID mItemID;
U8 mAttachmentPt;
BOOL mAdd;
};
+ typedef std::deque<AttachmentsInfo> attachments_vec_t;
+
+ LLAttachmentsMgr();
+ virtual ~LLAttachmentsMgr();
+
+ void addAttachmentRequest(const LLUUID& item_id,
+ const U8 attachment_pt,
+ const BOOL add);
+ void onAttachmentRequested(const LLUUID& item_id);
+ void requestAttachments(attachments_vec_t& attachment_requests);
+ static void onIdle(void *);
- typedef std::vector<AttachmentsInfo> attachments_vec_t;
+ void onAttachmentArrived(const LLUUID& inv_item_id);
+
+ void onDetachRequested(const LLUUID& inv_item_id);
+ void onDetachCompleted(const LLUUID& inv_item_id);
+
+private:
+
+ class LLItemRequestTimes: public std::map<LLUUID,LLTimer>
+ {
+ public:
+ LLItemRequestTimes(const std::string& op_name, F32 timeout);
+ void addTime(const LLUUID& inv_item_id);
+ void removeTime(const LLUUID& inv_item_id);
+ BOOL wasRequestedRecently(const LLUUID& item_id) const;
+ BOOL getTime(const LLUUID& inv_item_id, LLTimer& timer) const;
+
+ private:
+ F32 mTimeout;
+ std::string mOpName;
+ };
+
+ void removeAttachmentRequestTime(const LLUUID& inv_item_id);
+ void onIdle();
+ void requestPendingAttachments();
+ void linkRecentlyArrivedAttachments();
+ void expireOldAttachmentRequests();
+ void expireOldDetachRequests();
+ void checkInvalidCOFLinks();
+ void spamStatusInfo();
+
+ // Attachments that we are planning to rez but haven't requested from the server yet.
attachments_vec_t mPendingAttachments;
+
+ // Attachments that have been requested from server but have not arrived yet.
+ LLItemRequestTimes mAttachmentRequests;
+
+ // Attachments that have been requested to detach but have not gone away yet.
+ LLItemRequestTimes mDetachRequests;
+
+ // Attachments that have arrived but have not been linked in the COF yet.
+ std::set<LLUUID> mRecentlyArrivedAttachments;
+ LLTimer mCOFLinkBatchTimer;
+
+ // Attachments that are linked in the COF but may be invalid.
+ LLItemRequestTimes mQuestionableCOFLinks;
};
#endif