aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/linden/indra/llmessage/lluseroperation.cpp
diff options
context:
space:
mode:
authorJacek Antonelli2008-08-15 23:44:46 -0500
committerJacek Antonelli2008-08-15 23:44:46 -0500
commit38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4 (patch)
treeadca584755d22ca041a2dbfc35d4eca01f70b32c /linden/indra/llmessage/lluseroperation.cpp
parentREADME.txt (diff)
downloadmeta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.zip
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.gz
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.bz2
meta-impy-38d6d37f2d982fa959e9e8a4a3f7e1ccfad7b5d4.tar.xz
Second Life viewer sources 1.13.2.12
Diffstat (limited to 'linden/indra/llmessage/lluseroperation.cpp')
-rw-r--r--linden/indra/llmessage/lluseroperation.cpp180
1 files changed, 180 insertions, 0 deletions
diff --git a/linden/indra/llmessage/lluseroperation.cpp b/linden/indra/llmessage/lluseroperation.cpp
new file mode 100644
index 0000000..c3ce63c
--- /dev/null
+++ b/linden/indra/llmessage/lluseroperation.cpp
@@ -0,0 +1,180 @@
1/**
2 * @file lluseroperation.cpp
3 * @brief LLUserOperation class definition.
4 *
5 * Copyright (c) 2002-2007, Linden Research, Inc.
6 *
7 * The source code in this file ("Source Code") is provided by Linden Lab
8 * to you under the terms of the GNU General Public License, version 2.0
9 * ("GPL"), unless you have obtained a separate licensing agreement
10 * ("Other License"), formally executed by you and Linden Lab. Terms of
11 * the GPL can be found in doc/GPL-license.txt in this distribution, or
12 * online at http://secondlife.com/developers/opensource/gplv2
13 *
14 * There are special exceptions to the terms and conditions of the GPL as
15 * it is applied to this Source Code. View the full text of the exception
16 * in the file doc/FLOSS-exception.txt in this software distribution, or
17 * online at http://secondlife.com/developers/opensource/flossexception
18 *
19 * By copying, modifying or distributing this software, you acknowledge
20 * that you have read and understood your obligations described above,
21 * and agree to abide by those obligations.
22 *
23 * ALL LINDEN LAB SOURCE CODE IS PROVIDED "AS IS." LINDEN LAB MAKES NO
24 * WARRANTIES, EXPRESS, IMPLIED OR OTHERWISE, REGARDING ITS ACCURACY,
25 * COMPLETENESS OR PERFORMANCE.
26 */
27
28#include "linden_common.h"
29
30#include "lluseroperation.h"
31
32///----------------------------------------------------------------------------
33/// Local function declarations, constants, enums, and typedefs
34///----------------------------------------------------------------------------
35
36LLUserOperationMgr* gUserOperationMgr = NULL;
37
38///----------------------------------------------------------------------------
39/// Class LLUserOperation
40///----------------------------------------------------------------------------
41
42LLUserOperation::LLUserOperation(const LLUUID& agent_id)
43: mAgentID(agent_id),
44 mTimer()
45{
46 mTransactionID.generate();
47}
48
49LLUserOperation::LLUserOperation(const LLUUID& agent_id,
50 const LLUUID& transaction_id) :
51 mAgentID(agent_id),
52 mTransactionID(transaction_id),
53 mTimer()
54{
55}
56
57// protected constructor which is used by base classes that determine
58// transaction, agent, et. after construction.
59LLUserOperation::LLUserOperation() :
60 mTimer()
61{
62}
63
64LLUserOperation::~LLUserOperation()
65{
66}
67
68
69BOOL LLUserOperation::isExpired()
70{
71 const F32 EXPIRE_TIME_SECS = 10.f;
72 return mTimer.getElapsedTimeF32() > EXPIRE_TIME_SECS;
73}
74
75void LLUserOperation::expire()
76{
77 // by default, do do anything.
78}
79
80///----------------------------------------------------------------------------
81/// Class LLUserOperationMgr
82///----------------------------------------------------------------------------
83
84LLUserOperationMgr::LLUserOperationMgr()
85{
86}
87
88
89LLUserOperationMgr::~LLUserOperationMgr()
90{
91 if (mUserOperationList.size() > 0)
92 {
93 llwarns << "Exiting with user operations pending." << llendl;
94 }
95}
96
97
98void LLUserOperationMgr::addOperation(LLUserOperation* op)
99{
100 if(!op)
101 {
102 llwarns << "Tried to add null op" << llendl;
103 return;
104 }
105 LLUUID id = op->getTransactionID();
106 llassert(mUserOperationList.count(id) == 0);
107 mUserOperationList[id] = op;
108}
109
110
111LLUserOperation* LLUserOperationMgr::findOperation(const LLUUID& tid)
112{
113 user_operation_list_t::iterator iter = mUserOperationList.find(tid);
114 if (iter != mUserOperationList.end())
115 return iter->second;
116 else
117 return NULL;
118}
119
120
121BOOL LLUserOperationMgr::deleteOperation(LLUserOperation* op)
122{
123 size_t rv = 0;
124 if(op)
125 {
126 LLUUID id = op->getTransactionID();
127 rv = mUserOperationList.erase(id);
128 delete op;
129 op = NULL;
130 }
131 return rv ? TRUE : FALSE;
132}
133
134void LLUserOperationMgr::deleteExpiredOperations()
135{
136 const S32 MAX_OPS_CONSIDERED = 2000;
137 S32 ops_left = MAX_OPS_CONSIDERED;
138 LLUserOperation* op = NULL;
139 user_operation_list_t::iterator it;
140 if(mLastOperationConsidered.isNull())
141 {
142 it = mUserOperationList.begin();
143 }
144 else
145 {
146 it = mUserOperationList.lower_bound(mLastOperationConsidered);
147 }
148 while((ops_left--) && (it != mUserOperationList.end()))
149 {
150 op = (*it).second;
151 if(op && op->isExpired())
152 {
153 lldebugs << "expiring: " << (*it).first << llendl;
154 op->expire();
155 mUserOperationList.erase(it++);
156 delete op;
157 }
158 else if(op)
159 {
160 ++it;
161 }
162 else
163 {
164 mUserOperationList.erase(it++);
165 }
166 }
167 if(it != mUserOperationList.end())
168 {
169 mLastOperationConsidered = (*it).first;
170 }
171 else
172 {
173 mLastOperationConsidered.setNull();
174 }
175}
176
177
178///----------------------------------------------------------------------------
179/// Local function definitions
180///----------------------------------------------------------------------------