2
0
mirror of https://github.com/esiur/esiur-dotnet.git synced 2025-06-27 05:23:13 +00:00

New AsyncReply

This commit is contained in:
2019-12-31 12:44:54 +03:00
parent a96ddf602f
commit 3375a814e6
13 changed files with 470 additions and 61 deletions

View File

@ -60,6 +60,7 @@ namespace Esyur.Resource
private static Regex urlRegex = new Regex(@"^(?:([\S]*)://([^/]*)/?)");
private static object resourcesLock = new object();
static KeyList<string, Func<IStore>> getSupportedProtocols()
{
@ -591,12 +592,13 @@ namespace Esyur.Resource
public static bool Remove(IResource resource)
{
if (resource.Instance == null)
return false;
if (resources.ContainsKey(resource.Instance.Id))
resources.Remove(resource.Instance.Id);
lock(resourcesLock)
resources.Remove(resource.Instance.Id);
else
return false;
@ -604,12 +606,17 @@ namespace Esyur.Resource
{
stores.Remove(resource as IStore);
// remove all objects associated with the store
var toBeRemoved = resources.Values.Where(x =>
WeakReference<IResource>[] toBeRemoved;
lock (resourcesLock)
{
IResource r;
return x.TryGetTarget(out r) && r.Instance.Store == resource;
}).ToArray();
// remove all objects associated with the store
toBeRemoved = resources.Values.Where(x =>
{
IResource r;
return x.TryGetTarget(out r) && r.Instance.Store == resource;
}).ToArray();
}
foreach (var o in toBeRemoved)
{