diff options
author | Diva Canto | 2012-03-09 12:59:24 -0800 |
---|---|---|
committer | Diva Canto | 2012-03-09 12:59:24 -0800 |
commit | a58152bd2af64493e655d6f559bc366c38433187 (patch) | |
tree | 786bbae51662a948511f9d81d9211d2984676986 /OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |
parent | More on HG inventory transfers. Move the FireAndForget higher up. (diff) | |
download | opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.zip opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.tar.gz opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.tar.bz2 opensim-SC_OLD-a58152bd2af64493e655d6f559bc366c38433187.tar.xz |
More on inventory transfer hold ups:
- Added an inventory cache for caching root and system folders
- Synchronized the remote inventory connector, so that all the remote inventory calls are serialized
This will not make much difference in the hold ups. We'd have to move the FireAndForget high up to AddInventoryItem, but that opens up a can of worms regarding the notification of the recipient... the recipient would be notified of the offer before the items are effectively in his inventory, which could lead to surprises.
Diffstat (limited to 'OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs')
-rw-r--r-- | OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | 59 |
1 files changed, 59 insertions, 0 deletions
diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs new file mode 100644 index 0000000..0fe778d --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Inventory/InventoryCache.cs | |||
@@ -0,0 +1,59 @@ | |||
1 | using System; | ||
2 | using System.Collections.Generic; | ||
3 | |||
4 | using OpenSim.Framework; | ||
5 | using OpenMetaverse; | ||
6 | |||
7 | namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory | ||
8 | { | ||
9 | public class InventoryCache | ||
10 | { | ||
11 | private const double CACHE_EXPIRATION_SECONDS = 3600.0; // 1 hour | ||
12 | |||
13 | private static ExpiringCache<UUID, InventoryFolderBase> m_RootFolders = new ExpiringCache<UUID, InventoryFolderBase>(); | ||
14 | private static ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>> m_FolderTypes = new ExpiringCache<UUID, Dictionary<AssetType, InventoryFolderBase>>(); | ||
15 | |||
16 | public void Cache(UUID userID, InventoryFolderBase root) | ||
17 | { | ||
18 | lock (m_RootFolders) | ||
19 | m_RootFolders.AddOrUpdate(userID, root, CACHE_EXPIRATION_SECONDS); | ||
20 | } | ||
21 | |||
22 | public InventoryFolderBase GetRootFolder(UUID userID) | ||
23 | { | ||
24 | InventoryFolderBase root = null; | ||
25 | if (m_RootFolders.TryGetValue(userID, out root)) | ||
26 | return root; | ||
27 | |||
28 | return null; | ||
29 | } | ||
30 | |||
31 | public void Cache(UUID userID, AssetType type, InventoryFolderBase folder) | ||
32 | { | ||
33 | lock (m_FolderTypes) | ||
34 | { | ||
35 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
36 | if (!m_FolderTypes.TryGetValue(userID, out ff)) | ||
37 | { | ||
38 | ff = new Dictionary<AssetType, InventoryFolderBase>(); | ||
39 | m_FolderTypes.Add(userID, ff, CACHE_EXPIRATION_SECONDS); | ||
40 | } | ||
41 | if (!ff.ContainsKey(type)) | ||
42 | ff.Add(type, folder); | ||
43 | } | ||
44 | } | ||
45 | |||
46 | public InventoryFolderBase GetFolderForType(UUID userID, AssetType type) | ||
47 | { | ||
48 | Dictionary<AssetType, InventoryFolderBase> ff = null; | ||
49 | if (m_FolderTypes.TryGetValue(userID, out ff)) | ||
50 | { | ||
51 | InventoryFolderBase f = null; | ||
52 | if (ff.TryGetValue(type, out f)) | ||
53 | return f; | ||
54 | } | ||
55 | |||
56 | return null; | ||
57 | } | ||
58 | } | ||
59 | } | ||