diff options
author | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
---|---|---|
committer | dotnet-bot <dotnet-bot@microsoft.com> | 2015-01-30 14:14:42 -0800 |
commit | ef1e2ab328087c61a6878c1e84f4fc5d710aebce (patch) | |
tree | dee1bbb89e9d722e16b0d1485e3cdd1b6c8e2cfa /src/binder/inc/loadcontext.inl | |
download | coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.gz coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.tar.bz2 coreclr-ef1e2ab328087c61a6878c1e84f4fc5d710aebce.zip |
Initial commit to populate CoreCLR repo
[tfs-changeset: 1407945]
Diffstat (limited to 'src/binder/inc/loadcontext.inl')
-rw-r--r-- | src/binder/inc/loadcontext.inl | 91 |
1 files changed, 91 insertions, 0 deletions
diff --git a/src/binder/inc/loadcontext.inl b/src/binder/inc/loadcontext.inl new file mode 100644 index 0000000000..b8002e03cc --- /dev/null +++ b/src/binder/inc/loadcontext.inl @@ -0,0 +1,91 @@ +// +// Copyright (c) Microsoft. All rights reserved. +// Licensed under the MIT license. See LICENSE file in the project root for full license information. +// +// ============================================================ +// +// LoadContext.inl +// + + +// +// Implements the inlined methods of LoadContext template class +// +// ============================================================ + +#ifndef __BINDER__LOAD_CONTEXT_INL__ +#define __BINDER__LOAD_CONTEXT_INL__ + +template <DWORD dwIncludeFlags> +LoadContext<dwIncludeFlags>::LoadContext() : + SHash<AssemblyHashTraits<ContextEntry *, dwIncludeFlags> >::SHash() +{ + m_cRef = 1; +} + +template <DWORD dwIncludeFlags> +LoadContext<dwIncludeFlags>::~LoadContext() +{ + // Delete context entries and contents array + for (typename Hash::Iterator i = Hash::Begin(), end = Hash::End(); i != end; i++) + { + const ContextEntry *pContextEntry = *i; + delete pContextEntry; + } + this->RemoveAll(); +} + +template <DWORD dwIncludeFlags> +ULONG LoadContext<dwIncludeFlags>::AddRef() +{ + return InterlockedIncrement(&m_cRef); +} + +template <DWORD dwIncludeFlags> +ULONG LoadContext<dwIncludeFlags>::Release() +{ + ULONG ulRef = InterlockedDecrement(&m_cRef); + + if (ulRef == 0) + { + delete this; + } + + return ulRef; +} + +template <DWORD dwIncludeFlags> +ContextEntry *LoadContext<dwIncludeFlags>::Lookup(AssemblyName *pAssemblyName) +{ + ContextEntry *pContextEntry = + SHash<AssemblyHashTraits<ContextEntry *, dwIncludeFlags> >::Lookup(pAssemblyName); + + return pContextEntry; +} + +template <DWORD dwIncludeFlags> +HRESULT LoadContext<dwIncludeFlags>::Register(BindResult *pBindResult) +{ + HRESULT hr = S_OK; + ContextEntry *pContextEntry = NULL; + + SAFE_NEW(pContextEntry, ContextEntry); + + pContextEntry->SetIsDynamicBind(pBindResult->GetIsDynamicBind()); + pContextEntry->SetIsInGAC(pBindResult->GetIsInGAC()); + pContextEntry->SetIsSharable(pBindResult->GetIsSharable()); + pContextEntry->SetAssemblyName(pBindResult->GetAssemblyName(), TRUE /* fAddRef */); + pContextEntry->SetAssembly(pBindResult->GetAssembly()); + + if (pBindResult->GetIsFirstRequest()) + { + pContextEntry->SetIsFirstRequest(TRUE); + } + + SHash<AssemblyHashTraits<ContextEntry *, dwIncludeFlags> >::Add(pContextEntry); + + Exit: + return hr; +} + +#endif |