aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Framework
diff options
context:
space:
mode:
authorlbsa712008-01-02 09:07:11 +0000
committerlbsa712008-01-02 09:07:11 +0000
commit4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c (patch)
tree1ba334b56be2a096875f57e84e76f5d5ee73575e /OpenSim/Framework
parentPut warning codes explaining why some explicit bin/ScriptEngines paths were a... (diff)
downloadopensim-SC_OLD-4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c.zip
opensim-SC_OLD-4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c.tar.gz
opensim-SC_OLD-4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c.tar.bz2
opensim-SC_OLD-4b4ee9807054bdb06d7b1c3e0a5205836aff4f3c.tar.xz
* Trying to address TextureSender issues
* The BlockingQueue exposes Contains so we can make sure we don't add a TextureSender to the queue if there's already one present * introduced some TryGetValue and various code convention stuff
Diffstat (limited to 'OpenSim/Framework')
-rw-r--r--OpenSim/Framework/BlockingQueue.cs25
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetCache.cs6
-rw-r--r--OpenSim/Framework/Communications/Cache/AssetServerBase.cs38
-rw-r--r--OpenSim/Framework/Communications/Cache/SQLAssetServer.cs20
4 files changed, 48 insertions, 41 deletions
diff --git a/OpenSim/Framework/BlockingQueue.cs b/OpenSim/Framework/BlockingQueue.cs
index ae2a189..3ff3dac 100644
--- a/OpenSim/Framework/BlockingQueue.cs
+++ b/OpenSim/Framework/BlockingQueue.cs
@@ -32,27 +32,34 @@ namespace OpenSim.Framework
32{ 32{
33 public class BlockingQueue<T> 33 public class BlockingQueue<T>
34 { 34 {
35 private Queue<T> _queue = new Queue<T>(); 35 private readonly Queue<T> m_queue = new Queue<T>();
36 private object _queueSync = new object(); 36 private readonly object m_queueSync = new object();
37 37
38 public void Enqueue(T value) 38 public void Enqueue(T value)
39 { 39 {
40 lock (_queueSync) 40 lock (m_queueSync)
41 { 41 {
42 _queue.Enqueue(value); 42 m_queue.Enqueue(value);
43 Monitor.Pulse(_queueSync); 43 Monitor.Pulse(m_queueSync);
44 } 44 }
45 } 45 }
46 46
47 public T Dequeue() 47 public T Dequeue()
48 { 48 {
49 lock (_queueSync) 49 lock (m_queueSync)
50 { 50 {
51 if (_queue.Count < 1) 51 if (m_queue.Count < 1)
52 Monitor.Wait(_queueSync); 52 {
53 Monitor.Wait(m_queueSync);
54 }
53 55
54 return _queue.Dequeue(); 56 return m_queue.Dequeue();
55 } 57 }
56 } 58 }
59
60 public bool Contains(T item)
61 {
62 return m_queue.Contains(item);
63 }
57 } 64 }
58} \ No newline at end of file 65} \ No newline at end of file
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs
index 664625e..bd3437b 100644
--- a/OpenSim/Framework/Communications/Cache/AssetCache.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs
@@ -56,10 +56,10 @@ namespace OpenSim.Framework.Communications.Cache
56 56
57 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>(); 57 public Dictionary<LLUUID, AssetRequestsList> RequestLists = new Dictionary<LLUUID, AssetRequestsList>();
58 58
59 private IAssetServer m_assetServer; 59 private readonly IAssetServer m_assetServer;
60 60
61 private Thread m_assetCacheThread; 61 private readonly Thread m_assetCacheThread;
62 private LogBase m_log; 62 private readonly LogBase m_log;
63 63
64 /// <summary> 64 /// <summary>
65 /// 65 ///
diff --git a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
index 318082b..f0ed968 100644
--- a/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
+++ b/OpenSim/Framework/Communications/Cache/AssetServerBase.cs
@@ -37,11 +37,11 @@ namespace OpenSim.Framework.Communications.Cache
37{ 37{
38 public abstract class AssetServerBase : IAssetServer 38 public abstract class AssetServerBase : IAssetServer
39 { 39 {
40 protected IAssetReceiver _receiver; 40 protected IAssetReceiver m_receiver;
41 protected BlockingQueue<AssetRequest> _assetRequests; 41 protected BlockingQueue<AssetRequest> m_assetRequests;
42 protected Thread _localAssetServerThread; 42 protected Thread m_localAssetServerThread;
43 protected IAssetProvider m_assetProviderPlugin; 43 protected IAssetProvider m_assetProvider;
44 protected object syncLock = new object(); 44 protected object m_syncLock = new object();
45 45
46 // Temporarily hardcoded - should be a plugin 46 // Temporarily hardcoded - should be a plugin
47 protected IAssetLoader assetLoader = new AssetLoaderFileSystem(); 47 protected IAssetLoader assetLoader = new AssetLoaderFileSystem();
@@ -71,14 +71,14 @@ namespace OpenSim.Framework.Communications.Cache
71 MainLog.Instance.Verbose( 71 MainLog.Instance.Verbose(
72 "ASSET", "Asset {0} received from asset server", req.AssetID); 72 "ASSET", "Asset {0} received from asset server", req.AssetID);
73 73
74 _receiver.AssetReceived(asset, req.IsTexture); 74 m_receiver.AssetReceived(asset, req.IsTexture);
75 } 75 }
76 else 76 else
77 { 77 {
78 MainLog.Instance.Error( 78 MainLog.Instance.Error(
79 "ASSET", "Asset {0} not found by asset server", req.AssetID); 79 "ASSET", "Asset {0} not found by asset server", req.AssetID);
80 80
81 _receiver.AssetNotFound(req.AssetID); 81 m_receiver.AssetNotFound(req.AssetID);
82 } 82 }
83 } 83 }
84 84
@@ -95,11 +95,11 @@ namespace OpenSim.Framework.Communications.Cache
95 public AssetServerBase() 95 public AssetServerBase()
96 { 96 {
97 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system"); 97 MainLog.Instance.Verbose("ASSETSERVER", "Starting asset storage system");
98 _assetRequests = new BlockingQueue<AssetRequest>(); 98 m_assetRequests = new BlockingQueue<AssetRequest>();
99 99
100 _localAssetServerThread = new Thread(RunRequests); 100 m_localAssetServerThread = new Thread(RunRequests);
101 _localAssetServerThread.IsBackground = true; 101 m_localAssetServerThread.IsBackground = true;
102 _localAssetServerThread.Start(); 102 m_localAssetServerThread.Start();
103 } 103 }
104 104
105 private void RunRequests() 105 private void RunRequests()
@@ -108,7 +108,7 @@ namespace OpenSim.Framework.Communications.Cache
108 { 108 {
109 try 109 try
110 { 110 {
111 AssetRequest req = _assetRequests.Dequeue(); 111 AssetRequest req = m_assetRequests.Dequeue();
112 112
113 ProcessRequest(req); 113 ProcessRequest(req);
114 } 114 }
@@ -121,7 +121,7 @@ namespace OpenSim.Framework.Communications.Cache
121 121
122 public void SetReceiver(IAssetReceiver receiver) 122 public void SetReceiver(IAssetReceiver receiver)
123 { 123 {
124 _receiver = receiver; 124 m_receiver = receiver;
125 } 125 }
126 126
127 public void RequestAsset(LLUUID assetID, bool isTexture) 127 public void RequestAsset(LLUUID assetID, bool isTexture)
@@ -129,23 +129,23 @@ namespace OpenSim.Framework.Communications.Cache
129 AssetRequest req = new AssetRequest(); 129 AssetRequest req = new AssetRequest();
130 req.AssetID = assetID; 130 req.AssetID = assetID;
131 req.IsTexture = isTexture; 131 req.IsTexture = isTexture;
132 _assetRequests.Enqueue(req); 132 m_assetRequests.Enqueue(req);
133 133
134 MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID); 134 MainLog.Instance.Verbose("ASSET", "Added {0} to request queue", assetID);
135 } 135 }
136 136
137 public virtual void UpdateAsset(AssetBase asset) 137 public virtual void UpdateAsset(AssetBase asset)
138 { 138 {
139 lock (syncLock) 139 lock (m_syncLock)
140 { 140 {
141 m_assetProviderPlugin.UpdateAsset(asset); 141 m_assetProvider.UpdateAsset(asset);
142 m_assetProviderPlugin.CommitAssets(); 142 m_assetProvider.CommitAssets();
143 } 143 }
144 } 144 }
145 145
146 public void StoreAndCommitAsset(AssetBase asset) 146 public void StoreAndCommitAsset(AssetBase asset)
147 { 147 {
148 lock (syncLock) 148 lock (m_syncLock)
149 { 149 {
150 StoreAsset(asset); 150 StoreAsset(asset);
151 CommitAssets(); 151 CommitAssets();
@@ -154,7 +154,7 @@ namespace OpenSim.Framework.Communications.Cache
154 154
155 public virtual void Close() 155 public virtual void Close()
156 { 156 {
157 _localAssetServerThread.Abort(); 157 m_localAssetServerThread.Abort();
158 } 158 }
159 159
160 public void SetServerInfo(string ServerUrl, string ServerKey) 160 public void SetServerInfo(string ServerUrl, string ServerKey)
diff --git a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
index e4c278f..0a141c3 100644
--- a/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
+++ b/OpenSim/Framework/Communications/Cache/SQLAssetServer.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Framework.Communications.Cache
40 40
41 public SQLAssetServer(IAssetProvider assetProvider) 41 public SQLAssetServer(IAssetProvider assetProvider)
42 { 42 {
43 m_assetProviderPlugin = assetProvider; 43 m_assetProvider = assetProvider;
44 } 44 }
45 45
46 public void AddPlugin(string FileName) 46 public void AddPlugin(string FileName)
@@ -58,12 +58,12 @@ namespace OpenSim.Framework.Communications.Cache
58 { 58 {
59 IAssetProvider plug = 59 IAssetProvider plug =
60 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString())); 60 (IAssetProvider) Activator.CreateInstance(pluginAssembly.GetType(pluginType.ToString()));
61 m_assetProviderPlugin = plug; 61 m_assetProvider = plug;
62 m_assetProviderPlugin.Initialise(); 62 m_assetProvider.Initialise();
63 63
64 MainLog.Instance.Verbose("AssetStorage", 64 MainLog.Instance.Verbose("AssetStorage",
65 "Added " + m_assetProviderPlugin.Name + " " + 65 "Added " + m_assetProvider.Name + " " +
66 m_assetProviderPlugin.Version); 66 m_assetProvider.Version);
67 } 67 }
68 } 68 }
69 } 69 }
@@ -74,15 +74,15 @@ namespace OpenSim.Framework.Communications.Cache
74 { 74 {
75 base.Close(); 75 base.Close();
76 76
77 m_assetProviderPlugin.CommitAssets(); 77 m_assetProvider.CommitAssets();
78 } 78 }
79 79
80 protected override AssetBase GetAsset(AssetRequest req) 80 protected override AssetBase GetAsset(AssetRequest req)
81 { 81 {
82 AssetBase asset; 82 AssetBase asset;
83 lock (syncLock) 83 lock (m_syncLock)
84 { 84 {
85 asset = m_assetProviderPlugin.FetchAsset(req.AssetID); 85 asset = m_assetProvider.FetchAsset(req.AssetID);
86 } 86 }
87 87
88 return asset; 88 return asset;
@@ -90,12 +90,12 @@ namespace OpenSim.Framework.Communications.Cache
90 90
91 protected override void StoreAsset(AssetBase asset) 91 protected override void StoreAsset(AssetBase asset)
92 { 92 {
93 m_assetProviderPlugin.CreateAsset(asset); 93 m_assetProvider.CreateAsset(asset);
94 } 94 }
95 95
96 protected override void CommitAssets() 96 protected override void CommitAssets()
97 { 97 {
98 m_assetProviderPlugin.CommitAssets(); 98 m_assetProvider.CommitAssets();
99 } 99 }
100 } 100 }
101} \ No newline at end of file 101} \ No newline at end of file