forked from dotnet/runtime
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfailurecache.cpp
76 lines (60 loc) · 1.98 KB
/
failurecache.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
// Licensed to the .NET Foundation under one or more agreements.
// The .NET Foundation licenses this file to you under the MIT license.
// ============================================================
//
// FailureCache.cpp
//
//
// Implements the FailureCache class
//
// ============================================================
#include "failurecache.hpp"
namespace BINDER_SPACE
{
FailureCache::FailureCache() : SHash<FailureCacheHashTraits>::SHash()
{
// Nothing to do here
}
FailureCache::~FailureCache()
{
// Delete entries and contents array
for (Hash::Iterator i = Hash::Begin(), end = Hash::End(); i != end; i++)
{
const FailureCacheEntry *pFailureCacheEntry = *i;
delete pFailureCacheEntry;
}
RemoveAll();
}
HRESULT FailureCache::Add(SString &assemblyNameorPath,
HRESULT hrBindingResult)
{
HRESULT hr = S_OK;
NewHolder<FailureCacheEntry> pFailureCacheEntry;
SAFE_NEW(pFailureCacheEntry, FailureCacheEntry);
// No error occurred; report the original error
hr = hrBindingResult;
pFailureCacheEntry->GetAssemblyNameOrPath().Set(assemblyNameorPath);
pFailureCacheEntry->SetBindingResult(hrBindingResult);
Hash::Add(pFailureCacheEntry);
pFailureCacheEntry.SuppressRelease();
Exit:
return hr;
}
HRESULT FailureCache::Lookup(SString &assemblyNameorPath)
{
HRESULT hr = S_OK;
FailureCacheEntry *pFailureCachEntry = Hash::Lookup(assemblyNameorPath);
if (pFailureCachEntry != NULL)
{
hr = pFailureCachEntry->GetBindingResult();
}
return hr;
}
void FailureCache::Remove(SString &assemblyName)
{
FailureCacheEntry *pFailureCachEntry = Hash::Lookup(assemblyName);
// Hash::Remove does not clean up entries
Hash::Remove(assemblyName);
SAFE_DELETE(pFailureCachEntry);
}
};